driver.context无法可靠地返回webview

时间:2018-01-23 14:04:37

标签: python-2.7 appium appium-ios python-appium

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

0 个答案:

没有答案