我想使用 Appium 和 Node JS 点击 Android 键盘搜索按钮

问题描述 投票:0回答:1

我使用Appium,NodeJS

我想在输入框输入文本后点击移动键盘上的搜索按钮。但是下面的代码都没有被执行。 会不会和依赖有关系?喜欢司机?或者使用的库(webdriverio)?

有人有完整的指南吗?

完整代码:

const { remote } = require("webdriverio");

const capabilities = {
  "appium:platform": "Android",
  "appium:platformVersion": "11",
  "appium:automationName": "UiAutomator2",
  "appium:appPackage": "com.android.settings",
  "appium:appActivity": ".Settings",
  platformName: "Android",
  "appium:app":
    "/Users/ASUS/Downloads/MEmu Download/Showcaller-Caller-ID-Block-1.9.1(www.Farsroid.com).apk",
  "appium:deviceName": "Pixel 2 API 30",
  "appium:adv": "Pixel_2_API_30",
  "appium:autoGeneratePermissions": true,
  "appium:settings[ignoreUnimportantViews]": true,
};

const wdOpts = {
  hostname: process.env.APPIUM_HOST || "localhost",
  port: parseInt(process.env.APPIUM_PORT, 10) || 4723,
  logLevel: "info",
  capabilities,
};

async function runTest() {
  const driver = await remote(wdOpts);
  try {
    await driver.touchPerform([{ action: "tap", options: { x: 50, y: 50 } }]);

    await driver.touchAction({
        action: "tap",
        x: 50,
        y: 50,
      });
  } finally {
    await driver.pause(1000);
    await driver.deleteSession();
  }
}

runTest().catch(console.log);

模拟器: emulator

appium检查员: appium inspector

android node.js testing appium native
1个回答
0
投票

我找到了这个问题的答案

await driver.execute("mobile: performEditorAction", { action: "Search" });
© www.soinside.com 2019 - 2024. All rights reserved.