Hi everyone!
Is it possible that the use of the tap() method doesn't work on UITableViews when the cell is not visible? Official documentation says that the method should make the cell with the correspective identifier visible and then tap on it.
But if I try this code:
let app = XCUIApplication()
let myTableView = app.tables.element(matching: .table, identifier: "tableView01")
let myCell = myTableView.cells.element(matching: .cell, identifier: "tappableCell")
myCell.tap()
I get this error: << UITests.testP() failed: Computed invalid hit point (-1.2, -0.5) for Cell, 0x17419c7d0, traits: 8589934593, identifier: 'tappableCell' >>
And if I change the code into this:
let app = XCUIApplication()
let myTableView = app.tables.element(matching: .table, identifier: "tableView01")
myTableView.swipeUp(). //I swipe so that the cell becomes visible...
let myCell = myTableView.cells.element(matching: .cell, identifier: "tappableCell")
myCell.tap()
Nothing happens! On the command line I get the log as the action should've been computed but on the screen nothing happens!
Then I tried positioning a breakpoint just before the tap() method and giving the tap command manually from the command line writing 'po myCell.tap()' and it worked indeed! What's happening?! I have the same strange bug with both Xcode 8.3.3 and Xcode 9 - Beta 4.
Do you know any possible solution? Am I wrong in something? It could be related with my usage of accessibility identifiers to run the query?
Thank you for your support!
Andrea
We found a solution that doesn't require any change of your UITest script.
It appears that in Xcode 9 or iOS 11 the property "isAccessibilityElement" is disabled by default and hence isHittable always returns false.
You can enable this property in the Class file of your custom UICollectionViewCell.
See my answer on topic: https://forums.developer.apple.com/thread/90056#274418