是这样的,我在 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