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:
- Open the Test Navigator: You can access the test navigator by pressing Command + 6 in Xcode.
- 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.
- 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.
- 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
Go further with Swift Testing
Learn how to write a sweet set of (test) suites using Swift Testing’s baked-in features. Discover how to take the building blocks further and use them to help expand tests to cover more scenarios, organize your tests across different suites, and optimize your tests to run in parallel.
Xcode essentials
Edit, debug, commit, repeat. Explore the suite of tools in Xcode that help you iterate quickly when developing apps. Discover tips and tricks to help optimize and boost your development workflow.
Meet Swift Testing
Introducing Swift Testing: a new package for testing your code using Swift. Explore the building blocks of its powerful new API, discover how it can be applied in common testing workflows, and learn how it relates to XCTest and open source Swift.
What’s new in Xcode 16
Discover the latest productivity and performance improvements in Xcode 16. Learn about enhancements to code completion, diagnostics, and Xcode Previews. Find out more about updates in builds and explore improvements in debugging and Instruments.