This test in failing because
exceeds maximum length of 128 characters. You can work around this limitation by constructing a query with a custom NSPredicate that specifies the property (label, title, value, placeholderValue, or identifier) to match against.'
func testMessage() {
app.buttons["BEGIN"].tap()
let tablesQuery = app.tables
XCTAssert(tablesQuery.children(matching: .cell).element(boundBy: 0).staticTexts["<EXTREMELY LONG TEXT HERE (200chars)>"].exists)
}
How could I convert this so that I could work around the 128 char limit while testing the validity of the text.
You can use label LIKE
for your full string:
let yourSuperLongText = "your super long string"
let predicate = NSPredicate(format: "label LIKE %@", yourSuperLongText)
let element = tablesQuery.children(matching: .cell).element(boundBy: 0).staticTexts.element(matching: predicate)
XCTAssert(element.exists)
Or you can use label CONTAINS
for part of your string:
let partOfYoursSuperLongText = "part of your super long string"
let predicate = NSPredicate(format: "label CONTAINS[c] %@", partOfYoursSuperLongText)
let element = tablesQuery.children(matching: .cell).element(boundBy: 0).staticTexts.element(matching: predicate)
XCTAssert(element.exists)
More here: How to test that staticTexts contains a string using XCTest
and here: https://developer.apple.com/documentation/foundation/nspredicate
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