Appium server: 1.7.2 Appium-Python-Client==0.26 ios: 11.2
Using the following I would expect to find two views, native and a webview. The native view is always returned but 9/10 times it fails to return the webview context.
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()
Because the only finds the native context it obviously then fails with the following error ---
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