iOS UITesting与XCTest& Xcode - 测试动态添加的元素

时间:2016-04-05 18:49:05

标签: xcode swift xctest xcode-ui-testing xcode7.3

我有一个带两个开关的tableViewCell。一个总是存在,另一个是隐藏的,只有在我将UIPicker设置为特定值时才会出现。

在我的测试用例中,我将UIPicker设置为必要的值,如下所示:

var app = XCUIApplication()
let tablesQuery = app.tables
   tablesQuery.cells.childrenMatchingType(.TextField).elementBoundByIndex(1).tap()

app.pickerWheels["Value 1"].tap()
app.pickerWheels["Value 1"].adjustToPickerWheelValue("Value 2")
app.toolbars.buttons["Done"].tap()

查看模拟器,根据需要显示第二个开关。但是,app.switches无处可寻。

我试图重新加载XCUIApplication:

app = XCUIApplication()

但是在调试器中,当我打印出app.switches时,第二个开关不存在。我在Interface Builder中为它设置了标识符,但仍然没有。以下不起作用:

        let current401kToggle = app.switches.elementMatchingType(.Switch, identifier: "Value2Toggle")

任何帮助赞赏:) 谢谢!

0 个答案:

没有答案