【问题标题】:IOS: "Failed: Method is not implemented" error when I tried to perform some touch actionsIOS:当我尝试执行一些触摸操作时出现“失败:方法未实现”错误
【发布时间】:2018-04-23 14:19:15
【问题描述】:

我正在测试混合应用程序,并尝试在 iOS 上执行一些触摸操作,例如 WebView 上的 doubleTap 和 tapAndHold。我得到“失败:方法未实现”错误。

我尝试了以下代码:

browser.switchTo().frame(0);
return browser.touchActions().doubleTap(element).perform();

但是当我尝试时

return browser.touchActions().tap(element).perform();

一切正常。
对于 Android,此代码运行良好。

Appium:1.7.1
量角器:5.1.2
webdriver-manager 12.0.6.
MacOS 高山脉

那么如何在 iOS 上执行这种触摸操作呢?

conf.js:

var wd = require('wd'),
  wdBridge = require('wd-bridge')(require('protractor'), wd);
const config = {
  sync: false,
  seleniumAddress: 'http://localhost:4723/wd/hub',
  capabilities: {
    browserName: '',
    appiumVersion: "1.7.1",
    deviceName: "iPhone 8",
    deviceOrientation: "portrait",
    platformName: "iOS",
    platformVersion: "11.0",
    app:"",
    bundleId:'',
    launchTimeout: 20000,
    webviewConnectRetries: 1,
    autoAcceptAlerts: true,
    autoWebview: true,
    waitForAppScript: 'true',
    nativeInstrumentsLib:'false',
    showIOSLog:'false',
    newCommandTimeout: 5000
  },
  framework: 'jasmine2',
  allScriptsTimeout: 1500000,

  jasmineNodeOpts: {
    showColors: true,
    print: function () {
    },
    isVerbose: true,
    includeStackTrace: true,
    defaultTimeoutInterval: 1500000
  },
  suites: {
    smoke: ['./automation/smoke/*.js'],
  },
  beforeLaunch: function () {
    return new Promise(function (resolve) {
      reporter.beforeLaunch(resolve);
    });
  },
  onPrepare: function () {
    wdBridge.initFromProtractor(exports.config);
    browser.ignoreSynchronization = true;
    browser.wBridge=wdBridge;
    browser.getProcessedConfig()
      .then(function (config) {
        browser.appPackage = config.capabilities.appPackage;
        browser.bundleId = config.capabilities.bundleId;
        browser.deviceProperties = config.capabilities.deviceProperties;
        browser.platformname = config.capabilities.platformName;
        var iOSProperties = {'identifier': browser.bundleId},
          androidProperties = {'identifier': browser.appPackage},
          params = browser.platformname.toLowerCase() === 'iOS' ? androidProperties : iOSProperties;
        browser.ignoreSynchronization = true;
        wdBrowser.currentContext().then(function(context) {
          console.log('#context');
          console.log(context);
        });
      });

  },
  useAllAngular2AppRoots: true,
  restartBrowserBetweenTests: false
};
exports.config = config;

【问题讨论】:

  • 你试过.tap(element).tap(element)吗?
  • 是的,像两次轻击一样工作,而不是像双击一样

标签: javascript ios selenium protractor appium


【解决方案1】:
  1. wd 项目中没有doubleTap 函数,所以你得到的错误应该会看到。
  2. 如果你检查doubleTap 的appium 服务器命令,你会注意到wd 的客户端代码与tap 代码相同,所以看起来wd 还不支持doubleTap

到目前为止,我看到了 2 个选项:

1) 更多地使用wd 触摸动作中的现有功能,例如试试

const location = await element.getLocation()
const action = new wd.TouchAction()
action.press({x: location.x, y: location.y})
  .release()
  .press({x: location.x, y: location.y})
  .release()
await browser.performTouchAction(action)

2) 在 wd 项目中实现 doubleTap,查看来自 java 或 python 客户端的示例。

【讨论】:

    猜你喜欢
    • 2017-02-25
    • 2013-05-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-08
    • 1970-01-01
    相关资源
    最近更新 更多