======================================================================
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 的时候都会报错。请问,如何解决这个问题?