Appium 在 mac 上用 appium 测试 Android 真机发现的纠结问题,那位好心人能解答下 (python)

微风随意 · 2017年07月31日 · 最后由 微风随意 回复于 2017年08月01日 · 2143 次阅读

是这样的,我在 mac 上配置好了,然后也坚持了配置没有问题,然后就写了一个简单的 demo,就是打开 app,点击下注册按钮,可是运行老是报错。
1.代码如下:

#coding:utf-8
from appium import webdriver
from time import sleep

desired_caps={}
desired_caps['platformName']='Android'
desired_caps['platformVersion']='5.1.1'
desired_caps['deviceName']='HUAWEI P7-L07'
#desired_caps['app']=''
desired_caps['appPackage']='iHealthMyVitals.V2'
desired_caps['appActivity']='com.ihealth.login.welcome.User_Welcome'

dr = webdriver.Remote('http://127.0.0.1:4723/wd/hub',desired_caps)

sleep(3)

dr.find_element_by_id('iHealthMyVitals.V2:id/user_login_register_btn').click()

2.在 appium 上的配置如下

3.启动服务器如下

4.报错如下

/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 /Users/zhujiayu/PycharmProjects/test_appium/a.py
Traceback (most recent call last):
  File "/Users/zhujiayu/PycharmProjects/test_appium/a.py", line 13, in <module>
    dr = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
  File "build/bdist.macosx-10.11-intel/egg/appium/webdriver/webdriver.py", line 36, in __init__
  File "/Library/Python/2.7/site-packages/selenium-3.4.3-py2.7.egg/selenium/webdriver/remote/webdriver.py", line 98, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "/Library/Python/2.7/site-packages/selenium-3.4.3-py2.7.egg/selenium/webdriver/remote/webdriver.py", line 188, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/Library/Python/2.7/site-packages/selenium-3.4.3-py2.7.egg/selenium/webdriver/remote/webdriver.py", line 256, in execute
    self.error_handler.check_response(response)
  File "/Library/Python/2.7/site-packages/selenium-3.4.3-py2.7.egg/selenium/webdriver/remote/errorhandler.py", line 165, in check_response
    raise exception_class(value)
selenium.common.exceptions.WebDriverException: Message: Parameters were incorrect. We wanted {"required":["desiredCapabilities"],"optional":["requiredCapabilities","sessionId","id","sessionId","id"]} and you sent ["capabilities","desiredCapabilities"]


Process finished with exit code 1
共收到 3 条回复 时间 点赞


你在代码里面配置了 Android 机的各种参数,在 appium 上的配置还需要吗?,因为我看你报错信息就是 desiredCapabilities 这个参数你给的不对,你可以尝试只配置一端的。

selenium 版本太高了 降到 2 点几的版本就可以了

帝恨牧 回复

谢谢,顺利解决了,的确是 selenium 版本太高的问题

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册