Switch to WebView using getcontexthandles()

My code also not switching to Webview ,

System.out.println(((AppiumDriver) driver).getContextHandles());
		for (String contextName : ((AppiumDriver) driver).getContextHandles()) {
		    System.out.println(contextName);
		    if (contextName.contains("WEBVIEW")){
		    	((AppiumDriver) driver).context(contextName);
		    	System.out.println("Switched to " + contextName);
		    }
		}

It is showing only NATIVE_APP. But if I am executing with Selendroid it was working fine with the code

for(String winHandle : driver.getWindowHandles()){
				if (winHandle.contains("WEBVIEW"))
					driver.switchTo().window(winHandle);
				System.out.println(winHandle);
				}

Please help me on this

1 Like