5

I'm a new in Appium, I want to create a test to my Android app,

Using the inspector in Device Monitor, I found my element resource-id: com.appPackage:id/categoryIconImageView. and I used it like bellow. And I do not know why it's not working fine?

const wdio = require("webdriverio");

const opts = {
  port: 4723,
  desiredCapabilities: {
    platformName: "Android",
    deviceName: "emulator-5556 device",
    udid: "emulator-5554",
    platformVersion: "8.0.0",
    appPackage: "com.appPackage",
    appActivity: "com.appActivity",
    appWaitActivity: "com.appWaitActivity",
    noReset: "true",
  }
};

const client = wdio.remote(opts);

var s= client.init().element("#com.appPackage:id/categoryIconImageView").click().end();

Appium Log

[HTTP] --> POST /wd/hub/session/028abf5e-43a7-44f6-ab27-9d49e56bab8e/element
[HTTP] {"using":"-android uiautomator","value":"new UiSelector().resourceId('com.opensooq.OpenSooq:id/categoryIconImageView')"}
[debug] [MJSONWP] Calling AppiumDriver.findElement() with args: ["-android uiautomator","new UiSelector().resourceId('com.opensooq.OpenSooq:id/categoryIconImageView')","028abf5e-43a7-44f6-ab27-9d49e56bab8e"]
[debug] [BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator
[debug] [BaseDriver] Waiting up to 0 ms for condition
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"find","params":{"strategy":"-android uiautomator","selector":"new UiSelector().resourceId('com.opensooq.OpenSooq:id/categoryIconImageView')","context":"","multiple":false}}
[debug] [AndroidBootstrap] Received command result from bootstrap
[debug] [MJSONWP] Matched JSONWP error code 9 to UnknownCommandError
[HTTP] <-- POST /wd/hub/session/028abf5e-43a7-44f6-ab27-9d49e56bab8e/element 500 7 ms - 187
ِAmin
  • 162
  • 1
  • 17
  • I don't recognize the language. Keep in mind that an ID in android is not the same as an ID in HTML, at least as far as using xpath is concerned. It looks like you're using CSS but I'm not familiar with that, but the same thing almost certainly applies there. "resource-id" is not equal to "id" – Bill Hileman Aug 07 '18 at 19:51
  • I want to test android app – ِAmin Aug 07 '18 at 20:36

1 Answers1

5

I am using webdriver version ^6.6.3 and I can confirm that you can use:

client.$("id:resource-id-of-the-element");
Erisan Olasheni
  • 2,395
  • 17
  • 20