【问题标题】:Facing issue in handling date picker in iOS App while automation of ios application在 iOS 应用程序自动化时处理 iOS 应用程序中的日期选择器时面临的问题
【发布时间】:2020-06-01 06:24:53
【问题描述】:

在 iOS 应用程序自动化时处理 iOS 应用程序中的日期选择器时面临问题。

  1. 日期选择器始终显示当前日期。所以,它每天都在变化。
  2. 日期格式为MMM DD, YYYY
  3. 由于每天都在变化,因此很难通过滚动测量实现自动化。

代码

List<WebElement> dateValue = driver.findElementsByClassName("XCUIElementTypePickerWheel");

for (int i = 0; i < dateValue.size(); i++) {
    System.out.println(dateValue.get(i).getText());
}

dateValue.get(0).sendKeys("23");
dateValue.get(0).sendKeys(Keys.TAB);

dateValue.get(1).sendKeys("December");
dateValue.get(1).sendKeys(Keys.TAB);

dateValue.get(2).sendKeys("2000");
dateValue.get(2).sendKeys(Keys.TAB);

【问题讨论】:

    标签: selenium-webdriver appium appium-android appium-ios


    【解决方案1】:

    Appium 提供了名为selectPickerWheelValue 的mobile: 方法,可用于使用前后手势导航选择轮:

    HashMap<String, Object> params = new HashMap<>();
    params.put("order", "next");
    params.put("offset", 0.15);
    params.put("element", ((RemoteWebElement) pickerWheelElement).getId());
    driver.executeScript("mobile: selectPickerWheelValue", params);
    

    这种方法对选择值更加稳健。您可以查看完整示例here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-08-31
      • 1970-01-01
      • 1970-01-01
      • 2018-09-16
      • 2012-05-28
      • 1970-01-01
      • 2016-04-10
      • 2016-01-28
      相关资源
      最近更新 更多