Galet
Galet

Reputation: 6299

Replacement for name locator strategy in Appium version >= 1.5.0

I am writing Mobile App automation test cases for Android/iOS using java and appium.

I have upgraded my appium version from 1.4.16 to 1.5.3. Now I am not able use name locator.

name Locator:-

By.name("name here")

Remove long-deprecated name locator strategy in Appium v1.5

I have tried findElementByAccessibilityId locator. But this doesn't help me.

driver.findElementByAccessibilityId("name");

FYI I don't have specific id or class to use it. What is the replacement for name locator ?

Upvotes: 2

Views: 3655

Answers (2)

jarmy
jarmy

Reputation: 156

Using wildcards with xpath's can be very slow as it will scan the entire tree. It's also prone to returning the incorrect element if there are more than 1 item with the same name. Use precise locators wherever possible. Example: By.xpath("//UIAButton[@name='foo']")

Upvotes: 2

pappy-o
pappy-o

Reputation: 256

If accessibilityID isn't getting you there, have you tried using xpath with something like the below?

By.xpath("//*[@name='enter name here']")

Upvotes: 1

Related Questions