Menu
Who Do Is
  • Home
  • What
  • How
  • Is
  • Can
  • Are
  • Does
  • Do
  • Why
  • Who
  • Where
  • Which
  • Which
  • Should
  • Will
  • When
  • What’s
  • Did
Who Do Is

[ANSWERED] How to write xpath (get locator) for appium android automation?

Posted on November 14, 2022

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.

enter image description here

<?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

READ  [ANSWERED] How to create single backend website, iOS app and android app using flutter?
Powered by Inline Related Posts

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.

Recent Posts

  • How can I play with my cat without toys?
  • What is a bag pipe band called?
  • Are Honda Civics actually fast?
  • Are Yankee candles toxic?
  • How do I pair my Michael Kors smartwatch with my Android?

Recent Comments

No comments to show.

Archives

  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuántas
  • ¿Cuánto
  • ¿Que
  • ¿Quién
  • 90” and 108” so you may have to round up to the nearest size.
  • and delete any Spotify folders from it. Once this is done
  • Android
  • Are
  • At
  • Bei
  • blink
  • C'est
  • Can
  • carbs
  • Comment
  • Did
  • Do
  • Does
  • During
  • For
  • Has
  • How
  • In
  • Is
  • Ist
  • Kann
  • Können
  • nouveau
  • On
  • or 108 inches.2020-08-03
  • Où
  • owning
  • Pourquoi
  • Puis-je
  • Quand
  • Quante
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • spiritual
  • tap the downward-facing arrow on the top left. A downward-facing arrow will appear underneath each song in the album; they'll turn green as the download completes.2020-07-28
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welcher
  • Welches
  • Welke
  • Wer
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Whose
  • Why
  • Wie
  • Will
  • Wo
  • Woher
  • you will receive two curtains each with the same measurements of width 66"" (168cm) x drop 54""(137cm).
  • you'll see a green downward-facing arrow next to each song.2021-02-26
©2023 Who Do Is | Powered by SuperbThemes & WordPress