问题描述
我们最近将我们的移动 Nativescript 框架从版本 6.something 升级到了版本 7(最新)。这改变了各种下拉菜单的外观和功能,改为在我们的原生移动应用中显示列表选择器或数字选择器元素。
我正在使用 typescript/javascript 和 appium 来自动化我的移动测试。
现在我无法从这些类型的选择器中选择元素。我尝试了各种可以在网上找到的定位器和方法(老实说,那里的信息不多)。我曾尝试将 sendKeys 直接发送到选择器元素(它抱怨说你不能将键发送到这种类型的 android 元素),曾尝试在选择器中点击带有文本的元素(它跳过了这个,视觉上没有任何反应)等.
Here is example of how one of these pickers might look like
以下是我尝试使用的代码示例(注意 ios 代码有效,但 android 代码已被注释掉,因为这些是我尝试过的各种无济于事的东西):
public async selectDataFromDropdownNS7(dropdownData: string): Promise<void> {
// iOS
if (this.driver.isIOS) {
wait(2000)
const listPicker = await this.driver.findElementByClassName('UIAPickerWheel')
await listPicker.sendKeys(`${dropdownData}`)
await (await this.driver.findElementByText('Done')).tap()
} else {
// android.widget.EditText android.widget.NumberPicker android.widget.Button
const numberPicker = await this.driver.findElementByClassName('android.widget.EditText')
// const wd = this.driver.wd()
// const action = new wd.TouchAction(this.driver.driver)
// action
// .longPress({ x: 200,y: 1000 })
// .wait(5000)
// .moveto({ x: 200,y: 200 })
// .release()
// await action.perform()
// await numberPicker.sendKeys(dropdownData)
// await (await this.driver.findElementByText(`${dropdownData}`)).tap()
// await (await this.driver.findElementByText('Done')).tap()
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)