How to verify that a cell is visible as a table by testing the Xcode 7 interface?

I have a tabular view with a lot of cells, and not every cell is visible on the screen. When I check with

table.cells.staticTexts.matchingIdentifier("My Cell").element.exists 

It returns true, but the cell is not visible on the screen, and I can not click on it. Because whenever I click on it, the test fails.

How to check if an item is displayed on the screen? Or how to use an item that is not displayed?

+6
source share
4 answers

Use the hittable property instead of exists .

The link for XCUIElement explains that the hittable property hittable returns true if the item can be touched.

 table.cells.staticTexts.matchingIdentifier("My Cell").element.hittable 
+5
source

Instead of using element.exists, try using element.hittable. This worked for me, exists returns true if the item is currently in the display hierarchy, even if it is off-screen. hittable returns true only if the element is on the screen and its hittable.

0
source

The tableview method cellForRowAtIndexPath ( NOT the delegate method of the same name) will return the cell at a specific pointer path if it is currently displayed, or nil if it is not displayed.

If the user clicks the button (or something happens with any view in your cell), you can also go to the view hierarchy to find the cell first, then the table view and the indexPathForCell method will provide you with the index path of the cell.

0
source

you can use the swipeUp method to scroll down until a specific cell is visible. You can also check if this cell exists. something like that.

 XCUIElementQuery *tableQuery = app.tables; if (!tablesQuery.cells.staticText[@"some text"].exist){ [tablesQuery.staticTexts[@"visible cell text"] swipeUp]; } 
0
source

All Articles