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.

try

driver.findElement(By.xpath("//android.widget.TextView[@text=‘Markets’]")).click();

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’)]")
#elu.click()

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

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

#el78 = driver.find_element_by_id(“com.ambs.mobile:id/txtValue_Spinner”)
#el78.click()

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

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