Switch to WebView using getcontexthandles()

To switch between contexts in appium versions < 1.4.3 I used in C#:

var contextNames = driver.GetContexts();
driver.SetContext(contextNames[1]; ///for webview_1, for native_view 0

for the latest appium I had to change this code to only:
driver = new AndroidDriver<AppiumWebelement)(new Uri(“http://127.0.0.1:4723/wd/hub”), capabilities);
…some code here

driver.Context = “NATIVE_APP”;

so in your case it would be driver.Context = “WEBVIEW_1”;

hope this helps…took me a day to figure out the code change. :slight_smile:

Hi Lurita

Thank you for sharing the approach. Can you please share the complete method to open a webpage on real device Iphone using c#.

I am able to open the safari browser but not able to navigate to the desired webpage on the active browser.