代码很简单,就是微信打开到我的钱包页面,然后 driver.quit()
只是 macaca 的一个 bug 还是有什么解决办法?
python2.7
windows7SP1
macaca 1.1.21
from macaca.webdriver import WebDriver
from time import sleep
desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '6.0'
desired_caps['udid'] = 'C4Y5T16810004018'
desired_caps['reuse'] = '3'
desired_caps['package'] = 'com.tencent.mm'
desired_caps['activity'] = '.ui.LauncherUI'
desired_caps['androidProcess'] ='com.tencent.mm:tools'
server_url = {
'hostname': '127.0.0.1',
'port': 3456
}
driver = WebDriver(desired_caps, server_url)
driver.init()
sleep(2)
driver.element_by_xpath('//*[@text="我"]').click()
driver.element_by_xpath('//*[@text="钱包"]').click()
sleep(3)
driver.quit()
print 'Done'
跑完之后再我的钱包页面就停了,没有退出 app。
下面是 log
>> index.js:17:12 [master] pid:5048 webdriver server start with config:
{ port: 3456,
verbose: true,
always: true,
ip: '192.168.1.104',
host: 'LiN-PC',
loaded_time: '2017-02-09 22:35:05' }
>> middlewares.js:17:10 [master] pid:5048 base middlewares attached
>> router.js:127:10 [master] pid:5048 router set
>> webdriver sdk launched
>> responseHandler.js:11:12 [master] pid:5048 Recieve HTTP Request from Client:
method: POST url: /wd/hub/session, jsonBody: {"desiredCapabilities":{"androidPro
cess":"com.tencent.mm:tools","reuse":"3","package":"com.tencent.mm","udid":"C4Y5
T16810004018","autoAcceptAlerts":"True","activity":".ui.LauncherUI","platformNam
e":"Android"}}
>> session.js:47:10 [master] pid:5048 Creating session, sessionId: 582366a5-c3f5
-4ac4-b21e-3cd3ca804a1b.
INSTRUMENTATION_STATUS: numtests=1
INSTRUMENTATION_STATUS: stream=
com.android.uiautomator.client.Initialize:
INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
INSTRUMENTATION_STATUS: test=testStartServer
INSTRUMENTATION_STATUS: class=com.android.uiautomator.client.Initialize
INSTRUMENTATION_STATUS: current=1
INSTRUMENTATION_STATUS_CODE: 1
>> socket server ready
>> socket client ready
recive: {"cmd":"wake","args":{}}
return: {"success":true,"data":{"status":0,"value":true}}
recive: {"cmd":"alert","args":{"action":"registerAutoAcceptAlerts"}}
return: {"success":true,"data":{"status":0,"value":true}}
>> responseHandler.js:47:14 [master] pid:5048 Send HTTP Respone to Client: {"ses
sionId":"582366a5-c3f5-4ac4-b21e-3cd3ca804a1b","status":0,"value":"{\"androidPro
cess\":\"com.tencent.mm:tools\",\"reuse\":\"3\",\"package\":\"com.tencent.mm\",\
"udid\":\"C4Y5T16810004018\",\"autoAcceptAlerts\":\"True\",\"activity\":\".ui.La
uncherUI\",\"platformName\":\"Android\"}"}
>> responseHandler.js:11:12 [master] pid:5048 Recieve HTTP Request from Client:
method: POST url: /wd/hub/session/582366a5-c3f5-4ac4-b21e-3cd3ca804a1b/element,
jsonBody: {"using":"xpath","value":"//*[@text=\"我\"]"}
recive: {"cmd":"find","args":{"strategy":"xpath","selector":"//*[@text=\"我\"]",
"multiple":false}}
return: {"success":true,"data":{"status":0,"value":{"ELEMENT":"1"}}}
>> responseHandler.js:47:14 [master] pid:5048 Send HTTP Respone to Client: {"ses
sionId":"582366a5-c3f5-4ac4-b21e-3cd3ca804a1b","status":0,"value":"{\"ELEMENT\":
\"1\"}"}
>> responseHandler.js:11:12 [master] pid:5048 Recieve HTTP Request from Client:
method: POST url: /wd/hub/session/582366a5-c3f5-4ac4-b21e-3cd3ca804a1b/element/1
/click, jsonBody: {}
recive: {"cmd":"click","args":{"elementId":"1"}}
>> responseHandler.js:47:14 [master] pid:5048 Send HTTP Respone to Client: {"ses
sionId":"582366a5-c3f5-4ac4-b21e-3cd3ca804a1b","status":0,"value":"true"}
return: {"success":true,"data":{"status":0,"value":true}}
>> responseHandler.js:11:12 [master] pid:5048 Recieve HTTP Request from Client:
method: POST url: /wd/hub/session/582366a5-c3f5-4ac4-b21e-3cd3ca804a1b/element,
jsonBody: {"using":"xpath","value":"//*[@text=\"钱包\"]"}
recive: {"cmd":"find","args":{"strategy":"xpath","selector":"//*[@text=\"钱包\"]
","multiple":false}}
return: {"success":true,"data":{"status":0,"value":{"ELEMENT":"2"}}}
>> responseHandler.js:47:14 [master] pid:5048 Send HTTP Respone to Client: {"ses
sionId":"582366a5-c3f5-4ac4-b21e-3cd3ca804a1b","status":0,"value":"{\"ELEMENT\":
\"2\"}"}
>> responseHandler.js:11:12 [master] pid:5048 Recieve HTTP Request from Client:
method: POST url: /wd/hub/session/582366a5-c3f5-4ac4-b21e-3cd3ca804a1b/element/2
/click, jsonBody: {}
recive: {"cmd":"click","args":{"elementId":"2"}}
return: {"success":true,"data":{"status":0,"value":true}}
>> responseHandler.js:47:14 [master] pid:5048 Send HTTP Respone to Client: {"ses
sionId":"582366a5-c3f5-4ac4-b21e-3cd3ca804a1b","status":0,"value":"true"}
>> responseHandler.js:11:12 [master] pid:5048 Recieve HTTP Request from Client:
method: DELETE url: /wd/hub/session/582366a5-c3f5-4ac4-b21e-3cd3ca804a1b, jsonBo
dy: {}
>> session.js:80:12 [master] pid:5048 Delete session, sessionId: 582366a5-c3f5-4
ac4-b21e-3cd3ca804a1b
>> responseHandler.js:47:14 [master] pid:5048 Send HTTP Respone to Client: {"ses
sionId":"582366a5-c3f5-4ac4-b21e-3cd3ca804a1b","status":0}