Trying to do the Testing of Android Application coded in WebView. I have an app that I am trying to automate the Test Cases.
I have a login screen having Email and Password which does have id locaters. That is working fine I am able to locate elements. ITs hybrid app made with ionic. The login button does not have id locater.
So far I have tried this thing.
MobileWebBrowserFactory factory;
AndroidDriver<WebElement> appiumdriver;
WebElement LoginElement = appiumdriver.findElement(By.id("username"));
LoginElement.click();
LoginElement.sendKeys("Test");
WebElement PasswordElement = appiumdriver.findElement(By.id("password"));
PasswordElement.click();
PasswordElement.sendKeys("Test");
// Hide Keyboard
appiumdriver.hideKeyboard();
Thread.sleep(2000);
WebElement LoginButton = appiumdriver
.findElementByName("end");
it gave me an exception that name is not allowed locator to find all the times. I have used Android and appium drivers both.
Can anyone Suggest to me good libraries for this? I appreciate your help in advance.
Thanks
I didn't work with Appium for a long time, so maybe I'm wrong, but as I remember, Appium supports locating elements by id
or xpath
only.
So, instead of findElementByName
try findElementByXpath
.
The locator should be changed accordingly, so it will be something like
WebElement LoginButton = appiumdriver.findElementByXpath("//*[@name='end']");
I have done certain changes to the code.
Changed Appium Server to 1.10 to 1.20.2. Used Android Driver Instance.
Also, Used the Xpath for the non-ionic framework.
It resolved the issue for me and I am able to locate the element using this.
WebElement UsernameElement = appiumdriver.findElementByXPath("//*[@id=\"username\"]/input");
Thread.sleep(1000);
UsernameElement.click();
Thread.sleep(1000);
UsernameElement.sendKeys("[email protected]");
Maybe the Old Appium was not able to identify the element.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With