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?
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With