bemeyer
bemeyer

Reputation: 6231

swipeUp() on XCUIApplication breaks the XCUIApplication in UITest

We got a test where we need to swipeUp to see a cell inside of a tableView. After the swipeUp we cant event print out the app.tables. If we do not swipe everything works as expected.

Example:

func testSomethingInApp() {
   let app = XCUIApplication()
   app.launch()
   app.swipeUp() //after this we cant get app.tables anymore. Befor everything is fine
   XCTAssertEqual(app.tables.cells.elementBoundByIndex(5), "something") //something like this
}

Upvotes: 9

Views: 1907

Answers (2)

bemeyer
bemeyer

Reputation: 6231

Xcode 9 and Swift 4.0 does fix this issue. app.swipeUp() doesn't clear the tableview queried elements anymore.

Upvotes: 1

Mendigo dos Bytes
Mendigo dos Bytes

Reputation: 91

Try to access your element directly... app.staticText["something"]

When I wrote my UITests, I had some issues like these. I searched for the elements, putting breakpoints, and reading the output.

Print app in console using po app command.


enter image description here


Read the output, search for the element you want, see its type (if is a staticText, button, otherElements, whatever...)


enter image description here


See that all the elements available are displayed in output. The first word of each line in output is the type of each element.

In your code, access the type using: app.buttons to buttons, app.staticTexts to labels, etc...

JLU

Upvotes: 1

Related Questions