I am writing UI tests for our app. The sequence we need to test is:
- user swipes up to scroll the current table
- after the swipe ends, user taps a cell
It seems that the first tap after a swipe action is discarded. What's going on -- is this a bug? Code follows:
A table has 50 rows, each row containing the text "Row <number>", and tapping a row displays an alert.
This test succeeds:
let myTable = app.tables["AccId_MyTable"]
let row = myTable.cells.containing(.staticText, identifier: "Row 10").element
// Row 10 is visible initially
row.tap()
let okbutton = app.buttons["OK"]
XCTAssertTrue(okbutton.exists, "The tap alert never appeared")
okbutton.tap()This test fails on the okbutton.exists assert:
let myTable = app.tables["AccId_MyTable"]
let row = myTable.cells.containing(.staticText, identifier: "Row 10").element
// Adding this line causes the test to fail
myTable.swipeUp()
// Row 10 is still visible after the swipe up and should be tappable
// But .tap() fails
// Even adding a sleep(10) between .swipeUp() and .tap() doesn't fix it.
row.tap()
let okButton = app.buttons["OK"]
XCTAssertTrue(okButton.exists, "The tap alert never appeared")
okButton.tap()Footnote:
Another post I found said you don't need to swipe explicitly before tapping table cell. In our case we do need to swipe, because the swipe triggers the fetch of a new page of data, so without the swipe the table will not contain the element we need.