Writing UI tests in code
Being based on XCTest, we are already familiar with the assert functions, so that we'll use an XCTAssertEqual function. In order to retrieve the value in the topmost place, we have to find the right text field. XCUIApplication is a proxy to the interface of our app and it contains helper functions to access the elements.
XCUITest is based on the concept of queries; every element in the screen can be reached via a query and the script can send any kind of interaction, which will be executed at runtime. As we used app.buttons to reach the buttons, we'll use app.textFields. Being the text field we want to check, in the last position, we need to calculate its index position in the array, so we need to calculate its exact ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access