Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I check a cell is visible in a table view with Xcode 7 UI Testing?

I have a table view with a lot of cells and not every cell is visible on a 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 cannot tap on it. Because whenever I tap on it, a test fails.

How to check if an element is visible on a screen? Or how to tap on an element that is not visible?

like image 440
Tomáš Linhart Avatar asked Sep 03 '15 10:09

Tomáš Linhart


People also ask

How do I test UI in XCode?

How to Run XCUI Tests on XCode. To run the XCUITests on XCode, you can click the highlighted icon below to see your newly created UI Test targets. You can hover on the “testExample()” test case and click the “Play” icon to run that specific test to see if everything was set up properly.

What is a table view in XCode?

A table view displays a single column of vertically scrolling content, divided into rows and sections. Each row of a table displays a single piece of information related to your app. Sections let you group related rows together.


1 Answers

Use the hittable property instead of exists.

The class reference for XCUIElement explains that the hittable property will only return true if the element can be touched.

table.cells.staticTexts.matchingIdentifier("My Cell").element.hittable
like image 88
Oletha Avatar answered Oct 17 '22 22:10

Oletha