June 2017
Intermediate to advanced
256 pages
5h 38m
English
While testing an app, we often find the need to switch between the Web and native views. A typical example is the Facebook sign-in page in many apps or an intermediate payment page. In those situations, we need to change the application context to WEBVIEW or NATIVE. Use the following code snippet to switch to WebView:
public static void changeDriverContextToWeb(AppiumDriver driver) { Set<String> allContext = driver.getContextHandles(); for (String context : allContext) { if (context.contains("WEBVIEW")) driver.context(context); }}
It tries to get a list of all the context handles, checks whether there is any context that contains WebView, and then the driver switches to that context. The following ...
Read now
Unlock full access