Cannot find an item displayed on the screen

I’m doing an Appium course and I want to practice the “swipe” action with the “Photos” app in the iOS simulator but Appium is not able to find the element even though it is displayed on the screen

public void IOSSwipeTest(){
    Map<String,String> params = new HashMap<String,String>();
    driver.executeScript("mobile:launchApp", params);
    WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(5));
    wait.until(ExpectedConditions.presenceOfElementLocated(AppiumBy.iOSNsPredicateString("label == 'All Photos'")));
    driver.findElement(AppiumBy.accessibilityId("All Photos")).click();
    List<WebElement> allPhotos = driver.findElements(AppiumBy.iOSClassChain("**/XCUIElementTypeCell"));

This is my code and here ir the error

Expected condition failed: waiting for presence of element located by: AppiumBy.iOSNsPredicate: label == 'All Photos'

sometimes text not as label. try bullet proof:

"name == 'All Photos' OR value == 'All Photos' OR label == 'All Photos'"

just print output when fail:


here you see all elements and it values for example partial output:

<XCUIElementTypeButton type="XCUIElementTypeButton" enabled="true" visible="true" x="104" y="108" width="89" height="32" name="generated_UIView" label="Request">
                                              <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" enabled="true" visible="true" x="120" y="115" width="57" height="18" name="generated_Label" label="Request" value="Request">

use appium inspector:
to see the underline content and attributes of each element.

I am working with the appium inspector and none of the identifiers work for me

I have tried with other identifiers but it keeps failing

you can use AppiumBy.accessibilityId(“All Photos”) accessibilityId as you did although I am sceptical it will change something…

can you find the same element via appium inspector interactive interface(using the search sign)?
and if so, with which locator?

Try use ExpectedCondition.elementToBeClickable(…you locator…)
because you want to click the element afterwards and not just waiting for it to appear on the screen.