I’m looking to use predicate for finding elements as I read that Xpath should not be used and replaced with findElementByIosUIAutomation.
The Xpath looks like:
name: Pay a Bill
type: UIAButton
value:
label: Pay a Bill
enabled: true
visible: false
valid: true
location: {10, 328.10598754882812}
size: {394, 44}
xpath: //UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIAButton[4]
In trying to test this logic out, I’ve created this snippet to press a button. I’m I coding predicate wrong?
wait.until(ExpectedConditions.elementToBeClickable(((IOSDriver<?>) driver)
.findElementByIosUIAutomation(".buttons().firstWithPredicate(\"name CONTAINS 'Pay a Bill' \")"))).click();
It does not find it and reports the following error:
*** Element info: {Using=-ios uiautomation, value=.buttons().firstWithPredicate("name CONTAINS ‘Pay a Bill’ ")}
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.ios.IOSDriver.execute(IOSDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:363)
at io.appium.java_client.ios.IOSDriver.findElementByIosUIAutomation(IOSDriver.java:173)
at com.cri.fnbo.ios.accounts.PayABillDetails.payABillNotEnrolledInBillPay(PayABillDetails.java:100)