Macaca Macaca 运行到 webview 处报错

Tylan · 2017年02月07日 · 最后由 Tylan 回复于 2017年02月08日 · 1349 次阅读

======================================================================

ERROR: test_05_web (main.MacacaTest)

Traceback (most recent call last):
File "tests/macaca-ios-sample.test.py", line 177, in test_05_web
contexts = self.driver.contexts
File "/Library/Python/2.7/site-packages/macaca/webdriver.py", line 391, in contexts
return self._execute(Command.CONTEXT_HANDLES)
File "/Library/Python/2.7/site-packages/macaca/webdriver.py", line 66, in _execute
res = self.remote_invoker.execute(command, data)
File "/Library/Python/2.7/site-packages/macaca/remote_invoker.py", line 110, in execute
return self._request(method, url, body)
File "/Library/Python/2.7/site-packages/macaca/remote_invoker.py", line 145, in _request
res.raise_for_status()
File "/Library/Python/2.7/site-packages/requests/models.py", line 862, in raise_for_status
raise HTTPError(http_error_msg, response=self)
HTTPError: 500 Server Error: Internal Server Error for url: http://localhost:3456/wd/hub/session/15deb0b6-6a34-4e22-98f5-67401439a30f/contexts

我的 python 代码如下:

def test_05_web(self):
'''
switch_to_native(self.driver) \
.element_by_name('Baidu') \
.touch('tap')

time.sleep(3)
self.driver.save_screenshot("./baidu.png")

switch_to_webview(self.driver) \
.element_by_id('index-kw') \
.send_keys('macaca') \
.element_by_id('index-bn') \
.touch('tap')
'''
self.driver.element_by_name('Baidu').touch('tap')
time.sleep(3)
self.driver.save_screenshot("./baidu.png")
contexts = self.driver.contexts

self.driver.context = contexts[-1]
self.driver.element_by_id('index-kw') \
.send_keys('macaca') \
.element_by_id('index-bn') \
.touch('tap')

其中注释掉的部分为官方示例,官方示例也是跑不通,切换 context 的时候都会报错。请问,如何解决这个问题?

共收到 2 条回复 时间 点赞

@xdf 谢谢。contexts = self.driver.contexts 到这句就进行不下去了。

服务器端 log:
ios_webkit_debug_proxy path: /usr/local/bin/ios_webkit_debug_proxy

Error: Device: SIMULATOR does not exist.
at request.get.then.then.devices (/usr/local/lib/node_modules/macaca-ios/node_modules/.1.0.11@remote-debugger/lib/remote-debugger.js:47:17)
at tryCatcher (/usr/local/lib/node_modules/macaca-ios/node_modules/.2.11.0@bluebird/js/main/util.js:26:23)
at Promise._settlePromiseFromHandler (/usr/local/lib/node_modules/macaca-ios/node_modules/.2.11.0@bluebird/js/main/promise.js:510:31)
at Promise._settlePromiseAt (/usr/local/lib/node_modules/macaca-ios/node_modules/.2.11.0@bluebird/js/main/promise.js:584:18)
at Promise._settlePromises (/usr/local/lib/node_modules/macaca-ios/node_modules/.2.11.0@bluebird/js/main/promise.js:700:14)
at Async._drainQueue (/usr/local/lib/node_modules/macaca-ios/node_modules/.2.11.0@bluebird/js/main/async.js:123:16)
at Async._drainQueues (/usr/local/lib/node_modules/macaca-ios/node_modules/.2.11.0@bluebird/js/main/async.js:133:10)
at Immediate.Async.drainQueues (/usr/local/lib/node_modules/macaca-ios/node_modules/.2.11.0@bluebird/js/main/async.js:15:14)
at runCallback (timers.js:566:20)
at tryOnImmediate (timers.js:546:5)
at processImmediate as _immediateCallback

Listing devices on :9221

ios_webkit_debug_proxy exit with code: 0, signal: null

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册