Can't find element locator

I’m inspecting a mobile Appsing UI Automator viewer.Which having almost same path.

Note: I went into detail like

and used commands like
driver.findElement(By.xopath("//android.widget.TextView[@text, ‘Markets’]")).click();

But it’s not working.

try: driver.findElementByAndroidUIAutomator(new UiSelector().text(“Markets”)").click();
and make sure you do not have a typo in xpath:
driver.findElement(By.xpath("//android.widget.TextView[@text, ‘Markets’]")).click();

What do you have under (0) TextView: , above (1) TextView: Markets ?

@Zuzeac UiSelector can not to be resolved a type.



above one should work, if it doesn’t. Then it means that element was unable to found on DOM, so try to put explicit wait before clicking on that element. On other hand to make your code more dynamic you can take the layout of that bottom navigation bar then iterate by no of items and perform you required action(without taking these texts as a reference to the elemnts).

@Jagadeesh_T @Zuzeac

Hey, tried several ways to find my element, error still shows up.

  1. From the below list , tried all locator strategy, but no help.

#elu = driver.find_element_by_xpath("//*[contains(@text, ‘Baddebt Collection’)]")

elv = driver.find_element_by_xpath(’//android.widget.TextView[@text= “Baddebt Collection”]’)

#elk = driver.find_element_by_name(“Baddebt Collection”)

#el78 = driver.find_element_by_id(“”)

#elb = driver.find_element_by_xpath("//*[@name=‘Baddebt Collection’]")

the above fields can be detected which shown in Uiautomator screenshot, but not this one, any help