无法解决“没有名为Appium的模块”错误

时间:2019-04-30 04:27:25

标签: python eclipse appium browserstack

我正在使用浏览器堆栈设置自动化环境。我试图根据他们的指令实施以下代码:

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()

但是我遇到了以下错误:

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'

我已经通过Marketplace在Eclipse IDE中设置了Appium,但仍然无法解决问题。

2 个答案:

答案 0 :(得分:0)

确定要安装appium吗?如果不是,请通过点子pip install Appium-Python-Client安装它,然后尝试在代码中将Appium替换为appium。在我的系统中,它有效

答案 1 :(得分:0)

升级到Python 3,然后安装Appium。我也遇到过同样的问题,一旦更新到Python 3,它就可以解决。

  1. 卸载Python 2.7
  2. 安装Python 3及更高版本(最新版本:Python 3.7.4)
  3. 升级点数
  4. 安装Appium客户端(> pip安装appium-python-client)
  5. 然后运行脚本