Search code examples
seleniumxpathappiumandroid-uiautomatorinvalidselectorexception

Appium Unable to locate elements in mobile app using text in UIAutomator


When I try to use text in XPath, I am getting the error

org.openqa.selenium.InvalidSelectorException: Argument was an invalid selector (e.g. XPath/CSS). (WARNING: The server did not provide any stacktrace information)"

This is the code that i am trying to find an element

driver.findElement(By.xpath("//android.widget.EditText[@text=‘Enter recipient. Editing.’]")).sendKeys("8659741253");

Solution

  • Problem is with the text editor. " ‘ " character is not the expected single quote . So use the normal " ' ". Hope this will work.