【问题标题】:Appium-uiAutomator is working fine for android but not iOSAppium-uiAutomator 适用于 android 但不适用于 iOS
【发布时间】:2017-08-20 05:27:37
【问题描述】:

我正在尝试使用以下代码滚动到一个元素:

@AndroidFindBy(uiAutomator="new UiScrollable(new UiSelector()).scrollIntoView(" + "new UiSelector().text(\"Contacts\"));") @iOSFindBy(uiAutomator="new UiScrollable(new UiSelector()).scrollIntoView(" + "new UiSelector().text(\"Contacts\"));") 公共 MobileElement orgContact;

这在 Android 上完美运行,但在 iOS 上我收到以下错误: org.openqa.selenium.NoSuchElementException:无法通过此策略定位元素:定位器映射: - 原生内容:“By.IosUIAutomation: new UiScrollable(new UiSelector()).scrollIntoView(new UiSelector().text("Contacts"));”

我也尝试使用以下方式滚动: 公共无效垂直滚动(AppiumDriver驱动程序){

this.driver=driver;
dimensions = driver.manage().window().getSize();
Double screenHeightStart = dimensions.getHeight() * 0.5;
int scrollStart = screenHeightStart.intValue();
System.out.println("s="+scrollStart);
Double screenHeightEnd = dimensions.getHeight() * 0.2;
int scrollEnd = screenHeightEnd.intValue();
driver.swipe(0,scrollStart,0,scrollEnd,5000);

} 但它也不起作用。 谁能建议我在这里做错了什么

【问题讨论】:

    标签: appium appium-ios


    【解决方案1】:

    沙洛姆·罗尼特。

    您的代码不起作用的原因是因为您也为您使用了 Android 定位器策略@iOSFindBy,这是错误的,非常错误。

    根据您的 Xcode 版本,您可能无法在 iOS 上使用 UiAutomator(在 Xcode 8 中苹果已删除此选项)

    您必须使用 ID/Accessibility ID 甚至 Xpath。请花一些时间研究定位器策略、搜索示例以及如何正确查找 iOS 元素。

    我无法提供更多帮助,因为我不熟悉您尝试自动化的应用程序。这个元素有ID吗?是可见的还是您必须滚动才能找到它?你知道怎么用driver.findBy()?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-02-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多