3

How to locate item by accessbilityId (contentDescritpion) in Appium iOS and Android?

For me this code works:

When('I tap {}', (button) => {
    I.tap(button);
})

I have TabLayout and it can be found by android:contentDescription but how can I click some element of it? Setting content description to any of elements or its view is not working.

  <com.google.android.material.tabs.TabLayout
        android:id="@+id/tlNavigation"
        android:contentDescription="main_navigation_tab"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/white_max"
        app:layout_constraintBottom_toBottomOf="parent"
        app:tabIndicator="@null"
        app:tabMode="fixed" />

But if I want to get that button (that is set as content-description) is not working with javascript:

    let driver = appium.getDriver()
    let element = driver.findElement("id", listName)

How to locate those elements?

Kyryl Zotov
  • 1,788
  • 5
  • 24
  • 44

0 Answers0