【发布时间】:2020-02-15 16:55:34
【问题描述】:
我试图在我的应用程序启动后,使用 XPath 选择器在按钮元素上执行点击/按下操作。这个应用程序是一个混合应用程序(本机 + 一些 webviews)。
我遇到了一些问题,因为 Appium 的文档似乎具有误导性(可能)。
getDriver():
const driver = await remote({
capabilities: {
platformName: 'IOS',
browserName: 'mobileOS',
deviceName: config.deviceName,
securityToken: config.securityToken,
app: 'PUBLIC:my-app.ipa'
},
hostname: config.hostname,
path: config.path,
port: config.port,
logLevel: config.logLevel
});
以下是我启动和运行驱动程序的方法。这将启动设备,并打开我安装的应用程序。
我尝试执行点击或按下或单击操作:
const el = driver.$('//*[@name="MyButton"]');
driver.touchPerform([
{ action: 'press', options: { element: el } },
{ action: 'release'}
]);
我得到的错误是: 由于 java.util.LinkedHashMap 无法转换为 java.lang.String 导致请求失败
或
const el = driver.$('//*[@name="MyButton"]');
driver.touchPerform(
{ action: 'tap', options: { element: el } }
);
我得到的错误是: 获取 WebDriver 时出错:touchPerform 命令的“actions”参数类型错误 预期:对象[] 实际:对象
现在,我最初关注这个文档:http://appium.io/docs/en/commands/interactions/touch/tap/ 和/或http://appium.io/docs/en/commands/interactions/touch/touch-perform/
现在我可以理解为什么 touchPerform( press ) 可能无法工作,因为它在其他文档中指定它只能潜在地使用 x,y。
但水龙头是什么让我失望。如果我将在 driver.touchPerform 中发送的对象包装在一个数组中,如下所示:
const el = driver.$('//*[@name="MyButton"]');
driver.touchPerform([
{ action: 'tap', options: { element: el } }
]);
我得到与上一个相同的错误:Request failed due to java.util.LinkedHashMap cannot be cast to java.lang.String
我的问题是,我是否使用了错误的选择或触摸类型事件来点击移动设备上的按钮?
我也尝试过http://appium.io/docs/en/commands/element/actions/click/ 方法,当我尝试时它告诉我driver.$(..).click() is not a function
非常感谢任何帮助。
【问题讨论】:
标签: javascript ios appium webdriver-io perfecto