Set contextNames = driver.getContextHandles();
for (String contextName : contextNames) {
System.out.println(“Starting app”+contextNames);
} /// above code only returns NATIVE APP, even though for login verification the app switched to webview context, but appium does not recognises.
below is the details:
File appDir = new File(“C://sdk//build-tools//android-4.3”);
File app = new File(appDir, “Test.apk”);
//Set up desired capabilities and pass the Android app-activity and app-package to Appium
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“app”, app.getAbsolutePath());
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
capabilities.setCapability(CapabilityType.BROWSER_NAME, “Android”);
// capabilities.setCapability(CapabilityType.VERSION, “4.3”);
capabilities.setCapability(CapabilityType.PLATFORM, “Windows”);
capabilities.setCapability(CapabilityType.SUPPORTS_NETWORK_CONNECTION,true);
capabilities.setCapability(CapabilityType.SUPPORTS_WEB_STORAGE,true);
capabilities.setCapability(CapabilityType.SUPPORTS_SQL_DATABASE,true);
capabilities.setCapability(“app-package”, “com.home.simple”); // This is package name of your app (you can get it from apk info app)
capabilities.setCapability(“app-wait-activity”, “com.dynamicapp.Activity”);
capabilities.setCapability(“app-activity”, “com.dynamicapp.Activity”);
capabilities.setCapability(“device”,“Android”);
capabilities.setCapability(“platformName”, “Android”);
capabilities.setCapability(“deviceType”,“phone”);
capabilities.setCapability(“autoWebview”, true);
capabilities.setCapability(“deviceName”, “AVD”);
capabilities.setCapability(“newCommandTimeout”,24000);
capabilities.setCapability(“autoWebviewTimeout”,6000);
// This is Launcher activity of your app (you can get it from apk info app)
try {
driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
} catch(Exception e) {
e.printStackTrace();
}
I have the same issue when i run from the emulator. When I run it with the device. appium successfully identifies the webview. Please let me know if you come across a solution. Thank you.
Even i have the same issue,For me Appium gives Native as well as Webview on Emulator,But on Real device it gives just Native view.(Android device 4.4.2)
I have the same issue as Mayuresh_Shirodkar, I can see the WEBVIEW on an ANDROID emulator but when I try to run the same test against a real device with the same software level and app, only the NATIVE context is found. (Android 4.4.2)
Hi jonahss, Thanks for the suggestion. Yes, I have tried adding a ten second delay between opening the app and trying to access the webview but unfortunately that didn’t help. As I said, this works without any issues on an emulator running the same version of the app and the same API and software level as the real device.
I also tried upgrading to the latest version of appium (1.3 beta), I might try going to an older version and see if that helps.
I’m running into a similar issue, except I never change context because I’ve never had it work (chromedriver never connects and there’s nothing useful in the debug log). I’m stumped as to why I can still navigate and manipulate webview elements without ever changing context on nexus 5 running 4.4.2. The nexus is unlocked (I saw some info on forums claiming this “should” fix chromedriver issues, but it didn’t help me. Is this an actual requirement?)
See:
Hey Johnass,Even I have tried adding a ten second delay between opening the app and trying to access the webview,Din’t work for me too.
Anything else that can be tried?
I ran across the same issue on a real device and after trying to run Appium from the last master build, the webview was visible and it worked. Please do give it a try to run from master and let me know if it works for you too.
And please make sure that your webview is visible by assuring that:
I just tried appium 1.2.4 on a nexus 5 running both 4.4.2 and 4.4.4. The app does have the webview visible (verified by chrome remote debugger). Still no luck.
Hi, i am trying to automate Google search from device nexus 7 with 4.4.4. Below are the prerequisite.
Real device: Nexus 7 with 4.4.4
Browser: Chrome
Appium: 1.2.4.1 version
Java 1.7
Java-client 1.6.0
OS: Windows 8.1
I have written a code which open chrome, but when i am trying to switch to webview, it leads to no success. It only showing me context as “NATIVE_APP”. Whatever suggestion given in this post i have already tried, but no success. Please help me out to resolve this. Below is my code.
Code:
WebDriver driver;
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME, "Android");
capabilities.setCapability(CapabilityType.VERSION, "4.4.2");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("automationName", "Appium");
//capabilities.setCapability("appium-version", "1.2.4.1");
capabilities.setCapability("deviceName", "015d2994cc4c0618");
capabilities.setCapability("appPackage", "com.android.chrome"); // This is package name of your app (you can get it from apk info app)
capabilities.setCapability("appActivity", "com.android.chrome.Main"); // This is Launcher activity of your app (you can get it from apk info app)
driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
//here is WebElement instantiation
PageFactory.initElements(new AppiumFieldDecorator(driver), capabilities);
System.out.println(((AppiumDriver) driver).getOrientation());
//((AppiumDriver) driver).openNotifications();
System.out.println("done");
Thread.sleep(50000L);
Set<String> contextNames = ((AppiumDriver) driver).getContextHandles();
for (String contextName : contextNames) {
System.out.println(contextName);
((AppiumDriver) driver).context(contextName);
// System.out.println("it worked "+ driver.getTitle());
if (contextName.contains("WEBVIEW")){
((AppiumDriver) driver).context(contextName);
Thread.sleep(10000);
driver.findElement(By.id("sfdiv")).sendKeys("Appium");
String Text1 = driver.findElement(By.cssSelector(".module_operation_title")).getText();
System.out.println(Text1);
Thread.sleep(10000);
driver.findElement(By.cssSelector(".form_details")).click();
Thread.sleep(5000);
}