昨天试了多机运行失败后,发现之前一个简单的 demo 都不能正常运行了。
我的脚本
#coding:utf-8 from appium import webdriver from time import sleep
desired_caps = {}
desired_caps['platformName'] = 'Android'
#desired_caps['platformVersion'] = '4.1'
desired_caps['deviceName'] = '192.168.56.101:5555'
#desired_caps['udid']='192.168.56.101:5555'
#desired_caps['automationName'] = "Selendroid"
desired_caps['platformVersion'] = '4.4'
#desired_caps['deviceName'] = 'accf99bd'
#desired_caps['app'] = 'D:\apk\TBJ_4.2.0_online_0715_1405.apk'
#desired_caps['appPackage'] = 'com.tongbanjie.android'
#desired_caps['appActivity'] = '.TBJMainFragmentActivity'
desired_caps['appPackage'] = 'com.android.calculator2'
desired_caps['appActivity'] = '.Calculator'
dr = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
dr.find_element_by_id("com.android.calculator2:id/digit9").click()
dr.close_app()
dr.quit()
## 我的pycharm报错
```shell
C:\Python27\python.exe D:/appium/appiumtest.py
Traceback (most recent call last):
File "D:/appium/appiumtest.py", line 18, in <module>
dr = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
File "C:\Python27\lib\site-packages\appium\webdriver\webdriver.py", line 35, in __init__
super(WebDriver, self).__init__(command_executor, desired_capabilities, browser_profile, proxy, keep_alive)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 89, in __init__
self.start_session(desired_capabilities, browser_profile)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 138, in start_session
'desiredCapabilities': desired_capabilities,
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 193, in execute
response = self.command_executor.execute(driver_command, params)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 358, in execute
return self._request(command_info[0], url, body=data)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 426, in _request
resp = opener.open(request)
File "C:\Python27\lib\urllib2.py", line 431, in open
response = self._open(req, data)
File "C:\Python27\lib\urllib2.py", line 449, in _open
'_open', req)
File "C:\Python27\lib\urllib2.py", line 409, in _call_chain
result = func(*args)
File "C:\Python27\lib\urllib2.py", line 1227, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "C:\Python27\lib\urllib2.py", line 1197, in do_open
raise URLError(err)
urllib2.URLError: <urlopen error [Errno 10061] >
我的 appium server 界面:
在线等,server 成功启动的,但是运行脚本后,根本没有运行 server