Unable to click on button using UiSelector

I have a mobile screen which has 3 buttons and one of them is “Continue” button. All the buttons belong to same class and have same properties except text. I have used UiSelector class and then used text method to click on Continue button. However the test case has failed. Could you please guide me on this?

Is it possible to attach a screenshot of Inspector/UI Automator so we can guide you better.

Hi Anish

I have attached screen shots of the buttons and node detail of Continue button. All the properties of Continue, Button 2 and Exit buttons are same except the text value. Please note that the index value of these buttons is 0.

Please guide on this.

try these



Hi Anish

Thanks for your reply. I have tried both commands and received below error.

org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information)

Can you try with x and y and tap on it.

Firstly is there any specific requirement that you want to use UISelector ?

If not, you can try driver.findElement(By.name(“Continue”)).click()

If you want to use UiSelector,

driver.findElementByAndroidUIAutomator(“new UiSelector().text(”"+text+"")")

More details on UISelector @ http://developer.android.com/reference/android/support/test/uiautomator/UiSelector.html#descriptionContains(java.lang.String)