Ranjith Kasu
Ranjith Kasu

Reputation: 72

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");

Upvotes: 1

Views: 873

Answers (2)

undetected Selenium
undetected Selenium

Reputation: 193348

To send the text 8659741253 to the WebElement you can use the following line of code :

driver.findElement(By.xpath("//android.widget.EditText[contains(normalize-space(),'Enter recipient. Editing.')]")).sendKeys("8659741253");

Upvotes: 2

Pradeep hebbar
Pradeep hebbar

Reputation: 2267

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

Upvotes: 3

Related Questions