I want to check if an element on my ui which start with a prefix is present. How is it possible to implement it in Xcode 7 UI Tests?
app.tables["AAA"].staticTexts["Fax: 0049XXXXXXXX"].exists
I have three element into a tableview cell and only one (the third or last one) starts with the prefix Fax: 0049. How can i check the present of this element?
I tried with
app.tables["AAA"].cells.staticTexts.elementBoundByIndex(2).exists
But nothing, some ideas? Cheers
How to Run XCUI Tests on XCode. To run the XCUITests on XCode, you can click the highlighted icon below to see your newly created UI Test targets. You can hover on the “testExample()” test case and click the “Play” icon to run that specific test to see if everything was set up properly.
What is XCUITest framework? Developed by Apple in 2015, XCUITest is an automated UI test framework for performing iOS automation testing. It utilizes XCTest - an integrated test framework for Xcode by Apple.
You can use a BEGINSWITH
predicate to check if an element starts with a prefix.
let app = XCUIApplication()
let faxPredicate = NSPredicate(format: "label BEGINSWITH 'Fax: '")
let faxLabel = app.staticTexts.element(matching: faxPredicate)
XCTAssert(faxLabel.exists)
Here's a working example for selecting elements with a different BEGINSWITH
predicate, a picker with multiple wheels.
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