简体   繁体   English

UITest 日期时间选择器

[英]UITest DateTimePicker

I'm trying to UITest a form Built with Eureka forms on my iOS Swift project.我正在尝试在我的 iOS Swift 项目上对使用 Eureka forms 构建的表单进行 UITest。

Here's how the picker wheel looks.这是选择器轮的外观。 Its a TimeRow() on Eureka它是 Eureka 上的一个 TimeRow() 在此处输入图像描述

The problem is my UITest is unable to move the DateField.问题是我的 UITest 无法移动 DateField。 Its only able to move the hours and minutes field.它只能移动小时和分钟字段。 Here's the UITtest code这是 UITtest 代码

func testSetTime() {
        app.tables.cells.containing(.staticText, identifier: "Departure Time").element.tap()

        // unable to get this to work.
        app.datePickers.pickerWheels.element(boundBy: 0).adjust(toPickerWheelValue: "May 14")

        // these lines work perfectly.
        app.datePickers.pickerWheels.element(boundBy: 1).adjust(toPickerWheelValue: "01")
        app.datePickers.pickerWheels.element(boundBy: 2).adjust(toPickerWheelValue: "00")
        app.buttons["Done"].firstMatch.tap()
}

The error after running is as follows.运行后报错如下。

Unable to find current value 'May 17' in possible values 28 Mar, 29 Mar, 30 Mar, 31 Mar, 1 Apr, 2 Apr, 3 Apr, 4 Apr, 5 Apr, 6 Apr, 7 Apr, 8 Apr, 9 Apr, 10 Apr, 11 Apr, 12 Apr, 13 Apr, 14 Apr, 15 Apr, 16 Apr, 17 Apr, 18 Apr, 19 Apr, 20 Apr, 21 Apr, 22 Apr, 23 Apr, 24 Apr, 25 Apr, 26 Apr, 27 Apr, 28 Apr, 29 Apr, 30 Apr, 1 May, 2 May, 3 May, 4 May, 5 May, 6 May, 7 May, 8 May, 9 May, 10 May, 11 May, 12 May, 13 May, 14 May, 15 May, 16 May, 17 May, 18 May, 19 May, 20 May, 21 May, 22 May, 23 May, 24 May, 25 May, 26 May, 27 May, 28 May, 29 May, 30 May, 31 May, 1 Jun, 2 Jun, 3 Jun, 4 Jun, 5 Jun, 6 Jun, 7 Jun, 8 Jun, 9 Jun, 10 Jun, 11 Jun, 12 Jun, 13 Jun, 14 Jun, 15 Jun, 16 Jun, 17 Jun, 18 Jun, 19 Jun, 20 Jun, 21 Jun, 22 Jun, 23 Jun, 24 Jun, 25 Jun, 26 Jun, 27 Jun, 28 Jun, 29 Jun, 30 Jun, 1 Jul, 2 Jul, 3 Jul, 4 Jul, 5 Jul for the picker wheel "Today" PickerWheel无法在可能的值 3 月 28 日、3 月 29 日、3 月 30 日、3 月 31 日、4 月 1 日、4 月 2 日、4 月 3 日、4 月 4 日、4 月 5 日、4 月 6 日、4 月 7 日、4 月 8 日、4 月 9 日找到当前值“5 月 17 日” , 4月10日, 4月11日, 4月12日, 4月13日, 4月14日, 4月15日, 4月16日, 4月17日, 4月18日, 4月19日, 4月20日, 4月21日, 4月22日, 4月23日, 4月24日, 4月25日, 26日4月、4月27日、4月28日、4月29日、4月30日、5月1日、5月2日、5月3日、5月4日、5月5日、5月6日、5月7日、5月8日、5月9日、5月10日、5月11日、5月12日、 5月13日、5月14日、5月15日、5月16日、5月17日、5月18日、5月19日、5月20日、5月21日、5月22日、5月23日、5月24日、5月25日、5月26日、5月27日、5月28日、5月29日, 5月30日、5月31日、6月1日、6月2日、6月3日、6月4日、6月5日、6月6日、6月7日、6月8日、6月9日、6月10日、6月11日、6月12日、6月13日、6月14日、15日6月、6月16日、6月17日、6月18日、6月19日、6月20日、6月21日、6月22日、6月23日、6月24日、6月25日、6月26日、6月27日、6月28日、6月29日、6月30日、7月1日、 7 月 2 日、7 月 3 日、7 月 4 日、7 月 5 日用于选择器轮“今天”PickerWheel

Well, the framework specifies the problem fully you should use 17 May instead of May 17 .好吧,该框架完全指定了您应该使用17 May而不是May 17的问题。

app.pickerWheels.firstMatch.adjust(toPickerWheelValue: "17 May")

UPD更新程序

I have tried to interact with alike picker in the Calendar app (Xcode 11.4)我试图与日历应用程序(Xcode 11.4)中的相似选择器进行交互

Works just fine工作得很好

class siguiente: XCTestCase {

    func testExample() {
        // Given 
        let app = XCTApps.calendar.app
        app.launch()
        app.buttons["Add"].tap()
        app.staticTexts["Starts"].tap()

        // When
        let dateWheel = app.pickerWheels.firstMatch
        app.pickerWheels.firstMatch.adjust(toPickerWheelValue: "May 21")

        // Then
        XCTAssertEqual(dateWheel.value as? String, "Thu, May 21")
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM