Xcode ui test: staticTexts start with

I want to check if an element is present on my ui that starts with a prefix. How can I implement it in Xcode 7 interface tests?

app.tables["AAA"].staticTexts["Fax: 0049XXXXXXXX"].exists 

I have three elements in the tableview cell, and only one (third or last) starts with the Fax prefix: 0049. How can I check the present of this element?

I tried using

 app.tables["AAA"].cells.staticTexts.elementBoundByIndex(2).exists 

But nothing, some ideas? Greetings

+5
source share
1 answer

You can use the BEGINSWITH predicate to check if an element begins with a prefix.

 let app = XCUIApplication() let faxPredicate = NSPredicate(format: "label BEGINSWITH 'Fax: '") let faxLabel = app.staticTexts.element(matching: faxPredicate) XCTAssert(faxLabel.exists) 

Here is a working example for selecting items with another predicate BEGINSWITH , a multi-wheel assembler .

+13
source

Source: https://habr.com/ru/post/1243411/


All Articles