How to find out dynamic Content Names in Applium automation tools like Native Elements, Web Elements in Hybrid Application
// Find out the Content Names like NATIVE_APP, or WEBVIEW
in Hybrid Application
// Find out the Native Elements in Hybrid Application
Set<String> contextNames = driver.getContextHandles();
for (String contextName : contextNames) {
System.out.println(contextNames); //prints
out something like NATIVE_APP \n WEBVIEW_1
}
//Calling Native Elements
driver.context("NATIVE_APP");
// Find out the FIRST WEBPAGE and WEB Elements in Hybrid
Application
Set<String> contextNames = driver.getContextHandles();
for (String contextName : contextNames) {
System.out.println(contextNames); //prints
out something like NATIVE_APP \n WEBVIEW_1
}
driver.context(contextNames.toArray()[1]); // set
context to WEBVIEW_1
//Calling FIRST WEBPAGE AND Elements
driver.context("WEBVIEW_1");
// Find out the Dynamic Web Page and web elements in the
in Hybrid Application
driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"),
capabilities);
Set<String> contextNames = driver.getContextHandles();
for (String contextName : contextNames) {
System.out.println(contextNames); //prints
out something like NATIVE_APP \n WEBVIEW_1
//Calling DYNAMIC WEBPAGE and Elements
driver.context("contextNames");
}
Comments
Post a Comment