微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何从 Android 上的 Nativescript Picker 中选择

如何解决如何从 Android 上的 Nativescript Picker 中选择

我们最近将我们的移动 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 举报,一经查实,本站将立刻删除。