步骤是按
新手贴:Windows 平台上的使用 Python 语言实现 appium 自动化程序 for Android(完整版)http://testerhome.com/topics/646
这里操作的,我是直接到连接的真机,试了二台电脑,都提示这种错误,各位大牛来指教一下
android_contact.py 脚本
import os
from selenium import webdriver
# Returns abs path relative to this file and not cwd
PATH = lambda p: os.path.abspath(
os.path.join(os.path.dirname(__file__), p)
)
desired_caps = {}
desired_caps['device'] = 'Selendroid' #Selendroid Android
desired_caps['browserName'] = ''
desired_caps['version'] = '4.1.2'
desired_caps['app'] = PATH('E:\pythonDemo\ContactManager.apk')
desired_caps['app-package'] = 'com.example.android.contactmanager'
desired_caps['app-activity'] = '.ContactManager'
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
el = driver.find_element_by_name("Add Contact")
el.click()
textfields = driver.find_elements_by_tag_name("textfield")
textfields[0].send_keys("My Name")
textfields[2].send_keys("someone@somewhere.com")
driver.find_element_by_name("Save").click()
driver.quit()
appium 报错如下
info: Zip-aligning E:\pythonDemo\ContactManager.apk
info: Checking whether zipalign is present
info: [ADB] Using zipalign from D:\AndroidSDK\sdk\tools\zipalign.exe
debug: zipAlignApk: "D:\AndroidSDK\sdk\tools\zipalign.exe" -f 4 "E:\pythonDemo\ContactMana
ger.apk" "C:\Users\myhu\AppData\Local\Temp\appium114316-8764-uqq9fb.tmp"
error: uncaughtException: EXDEV, cross-device link not permitted 'C:\Users\myhu\AppData\Lo
cal\Temp\appium114316-8764-uqq9fb.tmp' date=Wed Apr 16 2014 21:51:35 GMT+0800 (中国标准时
间), pid=8764, uid=null, gid=null, cwd=C:\Users\myhu\AppData\Roaming\npm\node_modules\appi
um, execPath=D:\Program Files\nodejs\node.exe, version=v0.10.26, argv=[node, C:\Users\myhu
\AppData\Roaming\npm\node_modules\appium\bin\appium.js], rss=53436416, heapTotal=51602664,
heapUsed=26173080, loadavg=[0, 0, 0], uptime=2357.6278332, trace=[column=18, file=fs.js,
function=Object.fs.renameSync, line=543, method=fs.renameSync, native=false, column=10, fi
le=C:\Users\myhu\AppData\Roaming\npm\node_modules\appium\lib\devices\android\adb.js, funct
ion=null, line=465, method=null, native=false, column=7, file=child_process.js, function=C
hildProcess.exithandler, line=635, method=exithandler, native=false, column=17, file=event
s.js, function=ChildProcess.EventEmitter.emit, line=98, method=EventEmitter.emit, native=f
alse, column=16, file=child_process.js, function=maybeClose, line=743, method=null, native
=false, column=5, file=child_process.js, function=Process.ChildProcess._handle.onexit, lin
e=810, method=ChildProcess._handle.onexit, native=false], stack=[Error: EXDEV, cross-devic
e link not permitted 'C:\Users\myhu\AppData\Local\Temp\appium114316-8764-uqq9fb.tmp',
at Object.fs.renameSync (fs.js:543:18), at C:\Users\myhu\AppData\Roaming\npm\node_modu
les\appium\lib\devices\android\adb.js:465:10, at ChildProcess.exithandler (child_proce
ss.js:635:7), at ChildProcess.EventEmitter.emit (events.js:98:17), at maybeClose (
child_process.js:743:16), at Process.ChildProcess._handle.onexit (child_process.js:810
:5)]
python android_contact.py 报错如下:
E:\pythonDemo>python android_contact.py
Traceback (most recent call last):
File "android_contact.py", line 17, in <module>
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
File "D:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 71, in
__init__
self.start_session(desired_capabilities, browser_profile)
File "D:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 113, i
n start_session
'desiredCapabilities': desired_capabilities,
File "D:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 162, i
n execute
response = self.command_executor.execute(driver_command, params)
File "D:\Python27\lib\site-packages\selenium\webdriver\remote\remote_connection.py", lin
e 349, in execute
return self._request(command_info[0], url, body=data)
File "D:\Python27\lib\site-packages\selenium\webdriver\remote\remote_connection.py", lin
e 417, in _request
resp = opener.open(request)
File "D:\Python27\lib\urllib2.py", line 404, in open
response = self._open(req, data)
File "D:\Python27\lib\urllib2.py", line 422, in _open
'_open', req)
File "D:\Python27\lib\urllib2.py", line 382, in _call_chain
result = func(*args)
File "D:\Python27\lib\urllib2.py", line 1214, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "D:\Python27\lib\urllib2.py", line 1187, in do_open
r = h.getresponse(buffering=True)
File "D:\Python27\lib\httplib.py", line 1045, in getresponse
response.begin()
File "D:\Python27\lib\httplib.py", line 409, in begin
version, status, reason = self._read_status()
File "D:\Python27\lib\httplib.py", line 365, in _read_status
line = self.fp.readline(_MAXLINE + 1)
File "D:\Python27\lib\socket.py", line 476, in readline
data = self._sock.recv(self._rbufsize)
socket.error: [Errno 10054]