I have EditText with android:hint="oldtext"
. In Appium testing project find this element by Android UIAutomator:
WebElement element =
driver.findElementByAndroidUIAutomator("new UiSelector().text(\"oldtext\");
then I send new text to the element and invoke get method
element.sendKeys("newText");
element.getText();
I would like to assert new text but it throws NoSuchElementException
:
org.openqa.selenium.NoSuchElementException: UiSelector[TEXT=oldText]
For documentation on this error, please visit:
http://seleniumhq.org/exceptions/no_such_element.html
For appium you can use id, resource-id, cont-desc or xpath to uniquely identify the element. If you don't see any id or automationId (cont-desc) in your app element, it is good to ask your developer to put them in the code.
Using xpath is not recommended but you can use if there is no any id or cont-desc.
Now you can access the your element like following.
WebElement element= driver.findElement(By.id("element Id")).sendKeys("new Text");
//or
WebElement element = driver.findElementById("element id").sendKeys("new Text");
//using accessibility id
WebElement element = driver.findElementsByAccessibilityId("accesibility Id");
//using xpath
WebElement element = driver.findElement(By.xpath("//EditText[contains(@text,'oldtext')]"));