I am writing automation tests for a Hydrid App on Android. I have 2 problems:
-
From Appium Inspector, I see an element with attribute
resource-id: login_button
so I click this button with
androidDriver.findElement(By.id("login-button")).click();
and I get this error:
"An element could not be located with..."
Of course if I find element with
classname "android.widget.Button"
then it works. I asked developer, normally, resource-id would be like
resource-id: <APP_PACKAGE_NAME>:id/login_button
But he said for hydrid app he doesn't have bundleID (APP_PACKAGE_NAME). Is it correct that we don't have bundleID for Hydrid APP? And why Appium Inspector can see
"resource-id: login_button"
but this element could not be found and clickable?
-
So I also tried to switch context to WEBVIEW, with this code:
Set<String> contextHandles = appiumDriver.getContextHandles();
Map<String,String> hashMap= new HashMap<String,String>();
for (String contextname : contextHandles){
if (contextname.contains("NATIVE")){
hashMap.put("native", contextname);
} else {
hashMap.put("webview", contextname);
}
}
//webview
androidDriver.context(hashMap.get("webview"));
contextHandles has 2 values: NATIVE_APP and WEBVIEW_<APP_PACKAGE_NAME>. But when I set context to webview, I get error:
io.appium.java_client.NoSuchContextException: No such context found.
The App is built with Ionic 2 / Angular 2. This is what I see on Chrome://inspect
Can anyone please help? Thanks