selenium-webdriver - 无法使用 Appium 1.6 从 Spinner 中选择一个选项

标签 selenium-webdriver automated-tests appium android-testing android-uiautomator

我正在使用 Appium 1.6 来自动化 Android UI 测试。

在此图像中,我无法从微调器中选择任何国家/地区(例如:日本)。

screenshot

这是我正在使用的代码:

driver.findElement(By.id("com.akkipet.android:id/country_spinner__add_information")).click();    
driver.findElement(MobileBy.AndroidUIAutomator("new UiScrollable(new UiSelector()).scrollIntoView("+ "new UiSelector().text(\"India\"));")).click()

我究竟做错了什么?单击微调器后,虽然我无法读取国家/地区值,但我可以读取其他字段,例如名字、姓氏等。

现在,我正在使用点击功能在特定坐标处点击以选择所需的选项。但这将使其特定于设备。此外,由于选项列表因环境而异,我将不得不为每个环境提供一组不同的坐标。

点击代码:
touchAction.tap (200, 850).perform();

有人可以提出更好的解决方法吗?

最佳答案

试试这个。它对我有用。driver.findElement(By.id("com.akkipet.android:id/country_spinner__add_information")).click();
driver.findElement(By.name("India")).click();

关于selenium-webdriver - 无法使用 Appium 1.6 从 Spinner 中选择一个选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44701716/

相关文章:

javascript - python网络爬虫错误'没有这样的元素: Unable to locate element

java - 检测 webdriver 中是否选中单选按钮

android - 错误 : uncaughtException: Cannot read property 'sockets' of null from Appium for Android emulator

javascript - iOS 设备的远程访问

visual-studio - 在 Visual Studio 2015 中运行特定类别的测试

android - 如何在 React Native 中同时设置 testID 和 accessibilityLabel?

java - Selenium 3.7 : geckodriver : WebDriverException: org. apache.http.conn.HttpHostConnectException 连接被拒绝

java - Selenium 页面对象重用

c# - 使用 WatiN 处理内联 JavaScript 对话

automated-tests - casperjs 和 a/b 测试