Solution 1 :
The button you are about to click is inside android.webkit.WebView
. In other words, the app under test is an Android hybrid app.
To identify WebView elements, you should switch into the WebView first.
Java code for automating hybrid apps:
Set<String> contextNames = driver.getContextHandles();
for (String contextName : contextNames) {
System.out.println(contextName); //prints out something like NATIVE_APP, WEBVIEW_1
}
// Switching to webview
driver.context(contextNames.toArray()[1]); // set context to WEBVIEW_1
// do some web testing
String myText = driver.findElement(By.cssSelector(".green_button")).click();
// Switching back to NATIVE_APP
driver.context("NATIVE_APP");
// do more native testing if we want
driver.findElement(By.name("hello")).click();
driver.quit();
For more details, visit offical docs https://appium.io/docs/en/writing-running-appium/web/hybrid/
Solution 2 :
It looks like a hybrid app .You have to switch to web view context on execution.
For finding elements After launching the app you have to inspect using remote debugging.
https://developers.google.com/web/tools/chrome-devtools/remote-debugging
Solution 3 :
The xpath is:
‘hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.webkit.WebView/android.webkit.WebView/android.view.View’
which could be simplified to ‘hierarchy//android.view.View’
but the error message is telling you not to use an xPath
Problem :
I am writing the appium automation for android application, It does not have proper xpath, class name or ID.
Even in Image, you can clearly check that when I click on get started. It clicks whole frame. I have attached XML as well.
<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
<hierarchy index="0" class="hierarchy" rotation="0" width="1080" height="2040">
<android.widget.FrameLayout index="0" package="com.novo.android.dev" class="android.widget.FrameLayout" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,0][1080,2040]" displayed="true">
<android.widget.LinearLayout index="0" package="com.novo.android.dev" class="android.widget.LinearLayout" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,0][1080,2040]" displayed="true">
<android.widget.FrameLayout index="0" package="com.novo.android.dev" class="android.widget.FrameLayout" text="" resource-id="android:id/content" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,60][1080,2040]" displayed="true">
<android.widget.FrameLayout index="0" package="com.novo.android.dev" class="android.widget.FrameLayout" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,60][1080,2040]" displayed="true">
<android.webkit.WebView index="0" package="com.novo.android.dev" class="android.webkit.WebView" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,60][1080,2040]" displayed="true">
<android.webkit.WebView index="0" package="com.novo.android.dev" class="android.webkit.WebView" text="Plaid - Securely Connect" checkable="false" checked="false" clickable="false" enabled="true" focusable="true" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,60][1080,2040]" displayed="true">
<android.view.View index="0" package="com.novo.android.dev" class="android.view.View" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,60][1080,2040]" displayed="true" />
</android.webkit.WebView>
</android.webkit.WebView>
<android.widget.ProgressBar index="1" package="com.novo.android.dev" class="android.widget.ProgressBar" text="" resource-id="com.novo.android.dev:id/root_progress_bar" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[480,990][600,1110]" displayed="true" />
</android.widget.FrameLayout>
</android.widget.FrameLayout>
</android.widget.LinearLayout>
</android.widget.FrameLayout>
</hierarchy>
Comments
Comment posted by How to Ask
Is there a specific issue? Please see
Comment posted by photos.app.goo.gl/uKqJkuNeoTp3V6UK9
There is only one context. It’s showing. and that is native_app.how to switch to the WEBVIEW_1 Please check this.
Comment posted by photos.app.goo.gl/uKqJkuNeoTp3V6UK9
There is only one context. It’s showing. and that is native_app.how to switch to the WEBVIEW_1 Please check this.