How to build a query to get an element that contains another element by static text.
Example: Get the first table cell that contains a label with text "cool cell"
I need it because I have different cells and I want to get a cell that contains a specific text. Note that I'm interested to get the cell because I need to make sure that the cell contains another elements. The goal is to make sure that the cell with the title "I'm a cell" has also a label with text "cool"
Get the first table cell that contains a label with text "cool cell"
How about:
let app = XCUIApplication()
app.cells.containing(.staticText, identifier: "cool cell")
If that's not enough, there's a version of containing
that takes NSPredicate
:
func containing(_ predicate: NSPredicate) -> XCUIElementQuery
func containing(_ elementType: XCUIElement.ElementType, identifier: String?) -> XCUIElementQuery
Documentation:
Returns a new query for finding elements that contain a descendant matching the specification" which is what you need. [...]
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