4

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.

Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
  • As far as I know, the marketplace appium would be some kind of plugin, you will have to install appium on your machine, that should resolve the issue. – SRM21 Apr 30 '19 at 04:37
  • Any error if you do `python -c 'from Appium import webdriver'` in shell? – atline Apr 30 '19 at 05:54
  • @atline what does the above code will do? I have not done this before – Catherine Pequiño Apr 30 '19 at 05:59
  • Just same as you open python in bash terminal, and type `from Appium import webdriver`, this just to narrow your issue. As seems you run code in IDE? – atline Apr 30 '19 at 06:00
  • @atline yes, I run the code in Eclipse IDE. And when I do so, I encounter the error above. – Catherine Pequiño Apr 30 '19 at 06:24
  • Output of `python -c 'import os; print(os.__file__)'`? – atline Apr 30 '19 at 06:46
  • @atline this is the output: cathy0320:~ Cathy$ python -c 'from Appium import webdriver' Traceback (most recent call last): File "", line 1, in ModuleNotFoundError: No module named 'Appium' cathy0320:~ Cathy$ – Catherine Pequiño Apr 30 '19 at 08:07

3 Answers3

3

Upgrade to Python 3 and then install the Appium. I have faced the same issue and it get solved once updated to Python 3.

  1. Uninstall Python 2.7
  2. Install Python 3 & above (latest: Python 3.7.4 )
  3. upgrade the pip
  4. Install Appium client (> pip install appium-python-client)
  5. Then run the script
M.J
  • 152
  • 13
1

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

Kolay.Ne
  • 1,345
  • 1
  • 8
  • 23
  • You have to run pip as an administrator; if you have no pip, I guess, you can download and install it from python.org – Kolay.Ne Apr 30 '19 at 05:13
  • hi @Kolay.Ne I have already installed pip: Last login: Tue Apr 30 07:41:39 on console cathy0320:~ Cathy$ pip install Appium-Python-Client Requirement already satisfied: Appium-Python-Client in ./Library/Python/2.7/lib/python/site-packages (0.36) Requirement already satisfied: selenium>=3.14.1 in ./Library/Python/2.7/lib/python/site-packages (from Appium-Python-Client) (3.141.0) Requirement already satisfied: urllib3 in /Library/Python/2.7/site-packages (from selenium>=3.14.1->Appium-Python-Client) (1.24) cathy0320:~ Cathy$ – Catherine Pequiño Apr 30 '19 at 05:46
  • 1
    In python console run `import appium`. Everything in lowcase! What is the output? – Kolay.Ne Apr 30 '19 at 07:38
  • I have replaced 'Appium' to 'appium' already, but seems not fixed – Catherine Pequiño Apr 30 '19 at 12:49
  • 1
    Could you, please, check if the path to the apium module in your os.path? – Kolay.Ne Apr 30 '19 at 13:18
-1

Try replacing from Appium import webdriver with import apium.

Nirali
  • 1
  • 2
  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 01 '23 at 15:33
  • If you have a new question, please ask it by clicking the [Ask Question](https://stackoverflow.com/questions/ask) button. Include a link to this question if it helps provide context. - [From Review](/review/late-answers/34755291) – iantonuk Aug 02 '23 at 19:25