I am doing automation of Android native app and want to verify login validation with text. When I tried to pick it using Appium inspector and Uiautomator. Both unable to locate validation section so hard to pick it.
I tried code from different forums and Appium discussion but still unable to find that validation via automation. I've tried the following:
Code 1
JavascriptExecutor js = (JavascriptExecutor)driver;
WebElement field = driver.findElement(By.xpath("//android.widget.EditText[@text='Enter mobile number']"));
// Boolean is_valid = (Boolean)js.executeScript("return arguments[0].checkValidity();", field);
try {
String message = (String) js.executeScript("return arguments[0].validationMessage;", field);
} catch (Exception E) {
Output :
Exception : org.openqa.selenium.WebDriverException: Method has not yet been implemented
Code 2
public boolean IsValidationFired() {
if(driver.getPageSource().contains("Invalid")) {
System.out.println("PASS");
} else {
System.out.println("FAIL");
}
}
Output :
Print = FAIL
I am not sure if it is javascript popup or native app popup or toast message.But looking to inspect it and verify via automation.
Update
Code used to fire validation is : contactnu.setError("Invalid phone number.");