Click a CLASS element, which sits under ID element

Trying to click a class element, which sits under and ID element.
the ID (“toolbar”) is the father, and class (“android.widget.ImageButton”) is the child.

It looks like this:

What is the right syntax in order to access this element, using uiSelector?

I’ve tried to do this like this with no luck:
@AndroidFindBy(uiAutomator = “new UiScrollable(new UiSelector().resourceIdMatches(“toolbar”)).getChildByText(”
+ “new UiSelector().className(“android.widget.ImageButton”))”)

Thank you!

why not to try:


Thanks for your quick answer, Aleksei.
How to translate your code into something like this:

@AndroidFindBy(id = “toolbar”).MobileBy.ClassName(“android.widget.ImageButton”)

Finally, managed to solve this with CHAIN:

@HowToUseLocators(androidAutomation = LocatorGroupStrategy.CHAIN)
@AndroidFindBy(id = "toolbar")
@AndroidFindBy(className = "android.widget.ImageButton")
@iOSXCUITFindBy(accessibility = "back_button")
private WebElement backButton;

Thanks again

a bit more elegant:

    @iOSXCUITFindBy(accessibility = "back_button")
    @AndroidFindBys(value = {
            @AndroidBy(id = "toolbar"),
            @AndroidBy(className = "android.widget.ImageButton")
    private MobileElement backButton;
1 Like

Thank you again, Aleksei.
Worked like a charm.