How to write a query to search for text in a UI test?

Generated on 8/2/2024

1 search

To write a query to search for text in a UI test, you can use the filter field in the test navigator of Xcode. Here are the steps to do this:

  1. Open the Test Navigator: You can access the test navigator by pressing Command + 6 in Xcode.
  2. Use the Filter Field: At the bottom of the test navigator, there is a filter field where you can start typing the text you want to search for.
  3. Type Your Query: As you type, Xcode will suggest tags based on the ones available in your project. The filter field matches the test display and function names by default.
  4. Select Tags: If Xcode suggests tags that match your query, you can select them to narrow down your results. This will convert your typed text into a tag filter, showing only the tests with the selected tag.

For example, if you are looking for tests related to "spicy", you would type "spicy" in the filter field, and Xcode will suggest relevant tags. Selecting the "spicy" tag will filter the tests to show only those with the "spicy" tag.

For more detailed information, you can refer to the session Go further with Swift Testing.

Relevant Sessions