1 确保环境配置没有问题
2 Appium 服务端版本 1.5.3 python 客户端使用 Pycharm
3 python 代码:

import time
from appium import webdriver
desired_caps={}
desired_caps['platformName']= 'Android'
desired_caps['deviceName']= 'X4-40'
desired_caps['appPackage']= 'com.letv.tv'
desired_caps['appActivity']= 'com.letv.tv.player.PlayActivity'
#错误定位在下一行,具体原因未知
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
time.sleep(5)

4 通过单行注释,确定了问题所在行
5 具体错误见下:
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python /Users/rickyli/Downloads/Appium/venv/bin/01.py
Traceback (most recent call last):
File "/Users/rickyli/Downloads/Appium/venv/bin/01.py", line 10, in
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
File "/Library/Python/2.7/site-packages/appium/webdriver/webdriver.py", line 129, in init
proxy
File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 87, in init
self.start_session(desired_capabilities, browser_profile)
File "/Library/Python/2.7/site-packages/appium/webdriver/webdriver.py", line 204, in start_session
response = self.execute(RemoteCommand.NEW_SESSION, parameters)
File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 201, in execute
self.error_handler.check_response(response)
File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 102, in check_response
value = json.loads(value_json)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/init.py", line 338, in loads
return _default_decoder.decode(s)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 366, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 384, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

Process finished with exit code 1


↙↙↙阅读原文可查看相关链接,并与作者交流