Reputation: 41
I am setting up my environment for automation using browserstack. I tried to implement the following code based on their instructions:
from Appium import webdriver
enter code here`from Appium.webdriver.common.mobileby import MobileBy
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time
userName = "cathytest1"
accessKey = "5u8P4kxrPdw3bCDPtyCU"
desired_caps = {
"build": "Python Android",
"device": "Samsung Galaxy S8 Plus",
"app": "bs://fa77cdc35c9dea891b543c3ab6bf2897b300e229"
}
driver = webdriver.Remote("http://" + userName + ":" + accessKey + "@hub-
cloud.browserstack.com/wd/hub", desired_caps)
search_element = WebDriverWait(driver, 30).until(
EC.element_to_be_clickable((MobileBy.ACCESSIBILITY_ID, "Search
Wikipedia"))
)
search_element.click()
search_input = WebDriverWait(driver, 30).until(
EC.element_to_be_clickable((MobileBy.ID,
"org.wikipedia.alpha:id/search_src_text"))
)
search_input.send_keys("BrowserStack")
time.sleep(5)
search_results =
driver.find_elements_by_class_name("android.widget.TextView")
assert(len(search_results) > 0)
driver.quit()
But I got the following error:
Traceback (most recent call last):
File "/Applications/Eclipse.app/Contents/MacOS/C:\EclipseWorkspaces\csse120/Browserstack/src/Sample/__init__.py", line 1, in <module>
from Appium import webdriver
ModuleNotFoundError: No module named 'Appium'
I have already set up Appium in my Eclipse IDE via Marketplace but still, the issue isn't resolved.
Upvotes: 4
Views: 24380
Reputation: 1
It should be from appium import webdriver
.
The Appium when importing is Case Sensitive
Upvotes: 0
Reputation: 1
This is most probably because of you are using virtual environment. To resolve this issue open cmd. In cmd type cd <path\project.venv>(replace this path with your project directory and .venv with you virtual environment name. If you didn't give virtual environment name it is most likely be .venv). Now hit enter. After that type the command .\Scripts\activate (make sure that .venv is before the path in prompt (.venv) in my case (.venv) C:\Users\vibho\Documents\Pro\python\AI.venv>). Now just simply type pip install Appium. This will install Appium in your virtual environment.
Upvotes: 0
Reputation: 162
Upgrade to Python 3 and then install the Appium. I have faced the same issue and it get solved once updated to Python 3.
Upvotes: 4
Reputation: 1398
Are you sure you have appium installed? If no, install it via pip: pip install Appium-Python-Client
and then try to replace Appium
with appium
in your code. In my system, it worked
Upvotes: 1