小编ِAm*_*min的帖子

在Android中,使用Webdriverio,如何通过资源id选择元素?

我是 Appium 的新手,我想为我的 Android 应用程序创建一个测试,

使用设备监视器中的检查器,我找到了我的元素资源 ID:com.appPackage:id/categoryIconImageView。我像下面这样使用它。而且我不知道为什么它不能正常工作?

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();
Run Code Online (Sandbox Code Playgroud)

阿皮姆日志

[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] …
Run Code Online (Sandbox Code Playgroud)

android automated-tests android-testing appium webdriver-io

5
推荐指数
1
解决办法
3310
查看次数