I'm trying to automate an iOS app which was built using Pega PRPC. But i'm unable to find some elements.
Below is the elements section in appium,
Below is the code i used to refer that element,
private IOSDriver<MobileElement> driver;
URL url = new URL(configFileReader.getAppiumUrl());
driver = new IOSDriver<MobileElement>(url, cap);
MobileElement enterValueToHeadOnWeir = driver.findElementByClassName("XCUIElementTypeTextField");
enterValueToHeadOnWeir.sendKeys(configFileReader.getHeadOnWeirValue());
With the above code, i was able to get the element. But within the same screen I have same kind on text fields with the same className and it doesn't have any unique identifiers. For the first element this will work but i'm unable to work on other text fields.
As this is a PEGA App, i have "data-test-id" attribute for those elements, will i be able to use that with Appium?
If you have elements more than one with same specific, you can collect them in a list with .findelementsBy*
:
List<MobileElement> enterValueToHeadOnWeir = driver.findElementsByClassName("XCUIElementTypeTextField");
//example to second element
enterValueToHeadOnWeir.get(1).sendKeys(configFileReader.getHeadOnWeirValue());
This is index of element: .get(1)
.
But if you want still using "data-test-id"
you mean, you can achieve by xpath
:
MobileElement enterValueToHeadOnWeir = driver.findElementByXPath("//*[@elementId='enter_value_here']");
enterValueToHeadOnWeir.sendKeys(configFileReader.getHeadOnWeirValue());