我正在测试混合应用程序,我尝试在iOS上执行一些触摸操作,例如在WebView上的doubleTap和tapAndHold。我得到了"失败:方法未实施"错误。
我尝试了以下代码:
browser.switchTo().frame(0);
return browser.touchActions().doubleTap(element).perform();
但是当我尝试
时return browser.touchActions().tap(element).perform();
一切都好。 Appium:1.7.1
量角器:5.1.2
webdriver-manager 12.0.6。
MacOS High Sierra
那么如何在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;
答案 0 :(得分:0)
doubleTap
函数,因此您可能会看到错误。wd
客户端代码与tap代码相同,所以它实际上看起来像 doubleTap不是wd
支持 到目前为止,我看到了两个选项:
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客户端的示例。