Appium服务器:1.7.2 Appium的Python客户端== 0.26 ios:11.2
使用以下内容,我希望找到两个视图,原生视图和Web视图。始终返回本机视图,但是9/10次无法返回webview上下文。
contexts = self.driver.contexts
print "List of contexts " + str(contexts)
webview = contexts[1]
appview = contexts[0]
self.driver.switch_to.context(webview)
print "Switched to " + str(webview)
# Click on link in webview
self.driver.find_element_by_xpath('/html/body/p[2]/a').click()
因为只能找到原生上下文,所以它显然会因以下错误而失败---
test_1_sso (__main__.SmokeTest) ... List of contexts [u'NATIVE_APP']
ERROR
======================================================================
ERROR: test_1_sso (__main__.SmokeTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "test_sso_ios.py", line 121, in test_1_sso
webview = contexts[1]
IndexError: list index out of range