If you are with Java try use Appium annotations. They combine all possible values you can imagine.
Mine real example
@HowToUseLocators(iOSXCUITAutomation = LocatorGroupStrategy.ALL_POSSIBLE, androidAutomation = LocatorGroupStrategy.ALL_POSSIBLE)
@iOSXCUITFindAll(value = {
@iOSXCUITBy(iOSNsPredicate = "name == 'closeBarButton' AND visible == 1"),
@iOSXCUITBy(iOSNsPredicate = "name == 'backBarButton' AND visible == 1"),
@iOSXCUITBy(iOSNsPredicate = "name == 'Back' OR label == 'Back' AND visible == 1")
})
@iOSXCUITFindBys(value = {
@iOSXCUITBy(iOSNsPredicate = "type == 'XCUIElementTypeNavigationBar' AND visible == 1"),
@iOSXCUITBy(iOSNsPredicate = "type == 'XCUIElementTypeButton' AND visible == 1")
})
@AndroidFindAll(value = {
@AndroidBy(accessibility = "Navigate up"),
@AndroidBy(uiAutomator = "new UiSelector().resourceId(\"appbar.navigation\")"), // recurrent details
// back
@AndroidBy(id = "iv_back"),
// close
@AndroidBy(id = "iv_close"),
@AndroidBy(id = "iv_close_dialog"),
@AndroidBy(id = "close_button_cross"),
@AndroidBy(id = "iv_base_bottom_sheet_close") // Bottom Sheet close
})
@AndroidFindBys(value = {
@AndroidBy(uiAutomator = "new UiSelector().resourceIdMatches(\".*toolbar.*\")"),
@AndroidBy(className = "android.widget.ImageButton") // shitty android locator
})
@AndroidFindBys(value = { // onboarding
@AndroidBy(id = "entitlement_container"),
@AndroidBy(className = "android.widget.ImageButton")
})
private WebElement headerCloseOrBackButton;