Examples for findElementsByIosNsPredicate & findElementByIosNsPredicate

Hi,

I’m using the 5.0.0 beta simply because im really interested in using these apis:

findElementsByIosNsPredicate
findElementByIosNsPredicate

Currently I cannot figure out what string I should use to get it to work.
here are some attempts trying to access a button with the id: button_cart on the navigationbar:
None of these strings work for me.
The button is accessible as getElement(By.id(“button_cart”) does return the correct element.

Help me out please?

String test1 = “XCUIApplication()”;
String test2 = “XCUIApplication().navigationBar”;
String test3 = “XCUIApplication().navigationBar.buttons[“button_cart”]”;
String test4 = “.navigationBar.buttons[“button_cart”]”;
String test5 = “navigationBar.childrenMatchingType(.Button, identifier: “button_cart”)”;
String test6 = “label equals ‘button_cart’”;
String test7 = “identifier equals ‘button_cart’”;

System.out.println(driver.findElementsByIosNsPredicate(test1));
System.out.println(driver.findElementsByIosNsPredicate(test2));
System.out.println(driver.findElementsByIosNsPredicate(test3));

There is really a lack of documentation regarding the new iosPredicates in Appium :confused:

driver.findElements(MobileBy.iOSNsPredicateString("name MATCHES 'button_id'"));
driver.findElements(MobileBy.iOSNsPredicateString("label BEGINSWITH[cd] 'connection.'"));
driver.findElements(MobileBy.iOSNsPredicateString("value CONTAINS '" + firstName + " " + lastName + "'"));

I am still playing arround. Actually there should be also kind of type-checking.

Maybe these links can help you:
find_by_ios_predicate_tests.py
XCUITModeTest.java

2 Likes

works! Thank you so much

How do you do
is visible

wdVisible==‘1’
wdVisible==1
wdVisible==true

these aren’t working for me.

I am not using the isVisible attribute in that way, I always use a WebDriverWait for checking if the element is visible.
But I guess it is without “wd” just “visible == true”.