0

I am trying to convert my SeeTest suite to Appium, but I'm having one large issue:

I can't select elements by their @id attribute. When I try to select by ID, it says "element not found". When I view the apk through uiautomateviewer, no element @ids are visible.

SeeTest requires an apk to be an "instrumented" in order to select by @id. Is there any equivalent of "instrumentation" for Appium?

dbc
  • 104,963
  • 20
  • 228
  • 340
Jared Loomis
  • 795
  • 1
  • 5
  • 8

3 Answers3

0

A good rule of thumb is that if it does not appear in the Appium inspector, do no use it. What you could do is something along the lines of:

driver.findElement(By.xpath("//<UIElementType[contains(@<identifier>, '<identifier value>')]>");

Where identifier can be

  • name or content-desc

  • label

  • text

and a few more.

Hopefully this will help with your changes.

JaysonP
  • 164
  • 1
  • 10
  • Well, I have a large automation framework already in place using id's (with SeeTest as the backend). I just want to make Appium behave the same as SeeTest with respect to id's – Jared Loomis Sep 16 '16 at 19:36
  • name does not work on android. neither does label. Your best bets are resource-id, content-desc, and text. – njzk2 Sep 16 '16 at 19:37
  • I do not have access to my appium code currently but is it possible to find it in the same manner I stated above but using `contains(@resource-id, 'com.package.path.id')` Otherwise I don't know if there is a way to find in a similar way. Can you possible show me an example of how your SeeTest works. I am unfamiliar with it. – JaysonP Sep 16 '16 at 19:41
  • Like `njzk` stated name will not work, on Android it is known as content-desc however if you are trying to find the attibute `content-desc` you need to use `element.getAttribute("name");` where element is of type AndroidElement – JaysonP Sep 16 '16 at 20:24
0
public void athenaclick(String element) {
    WebElement webElement = driver.findElement(By.id(element));
    webElement.click();
    System.out.println("Click element: "+element);
}   

In seetest when you instrument you get extra properties which might not be available when in appium eg: text colour as seetest is a paid tool and appium is a open source.

Maximilian Ast
  • 3,369
  • 12
  • 36
  • 47
0

Turns out this was because Appium only supports selection by id with Android API level 18+. I was on 17, so I switched to the Selendroid Appium backend.

Jared Loomis
  • 795
  • 1
  • 5
  • 8