Skip to content Skip to sidebar Skip to footer

How To Fix "can't Locate An Element By This Strategy: Locator Map:"

Can't locate an element by this strategy: Locator map: - native content: 'By.xpath: //android.widget.ImageView[id='toolbar_search_place']' - html content: 'by id or name 'ClkSear

Solution 1:

If you are looking only by the ID value the correct solution should be following: By.id("toolbar_search_place")

If you are using resource-id attribute then you have to match exact value from the page element XML e.g. By.xpath("//android.widget.ImageView[@resource-id='<resource_id_value>']")

NOTE! resource-id =/= id

UPDATE!

So in this particular XML case your xpath should look like following:

By.xpath("//android.widget.ImageView[@resource-id='com.senrysa.veiculu:id/toolbar_search_place']")

More information about XPath: W3schools XML and XPath

Solution 2:

Accepted answer is correct.

More Improvement.

WebDriverWait wait;
    publicHpSancSignInME(AndroidDriver<MobileElement> driver) {
        PageFactory.initElements(new AppiumFieldDecorator(driver), this);
        wait = new WebDriverWait(driver, 60);

    }

public MobileElement getSignBtn() {
        wait.until(ExpectedConditions.elementToBeClickable(signBtn));
        return signBtn;
    }

Post a Comment for "How To Fix "can't Locate An Element By This Strategy: Locator Map:""