Switch to Webview (For real device)

To make appium recognise the webview context, we need to make sure that we have ios_webkit_debug_proxy installed correctly and is the latest version. Otherwise, use brew install ios_webkit_debug_proxy or brew update ios_webkit_debug_proxy.

Then run the code ios_webkit_debug_proxy -c YourUDIDHere:27753 -d so that webkit can focus on your device.

The following code can help us switch to webview (in C#):

var contextList = CommonMethod.driver.Contexts;

foreach (String contextname in contextList)

{

Console.WriteLine(contextname);

if (contextname.Contains(“WEBVIEW”))

{

CommonMethod.driver.Context = contextList.ToArray()[1];//Switch to webview

Console.WriteLine(contextList.ToArray()[1]);

break;

}

}

Based on the result writen in console, you can find out which one is webview. For me, is contextList[1].

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s