Find an element with different IDs

I’m trying to automate the step click on a button in iPhone and iPad. For iPhone the id is “canBeIdOne” and for iPad the id is “canBeIdTwo”. What’s the best way to search for this element using Page object model so that it works for both iPad and iPhone.

If I try below approach, then It always searches for accessibility = “canBeIdOne” and fails with error “unable to find an element” and never tries to search using the accessibility = “canBeIdTwo”.

One of the approach is
@iOSXCUITFindBy(accessibility = “canBeIdOne”),
@iOSXCUITFindBy(accessibility = “canBeIdTwo”)
@AndroidFindBy(id = “:id/isOneAlways”)
public MobileElement btnName;

What’s the best strategy to find the same element with different ids on iPhone and iPad.

@shettar to find any (just make same for iOS):

    @HowToUseLocators(androidAutomation = LocatorGroupStrategy.ALL_POSSIBLE)
    @AndroidFindBy(id = "newID")
    @AndroidFindBy(id = "oldID") // old devices
    private List<AndroidElement> someButton;

to read:

1 Like

@Aleksei, Awesome. Will try it out today.

Thanks a lot.

@Aleksei Wow it worked!