How to test that staticTexts contains a string using XCTest

You can use NSPredicate to filter elements.

  let searchText = "the content of the staticText"
  let predicate = NSPredicate(format: "label CONTAINS[c] %@", searchText)
  let elementQuery = app.staticTexts.containing(predicate)
  if elementQuery.count > 0 {
    // the element exists
  }

With CONTAINS[c] you specify that the search is case insensitive.

Have a look at Apples Predicate Programming Guide

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)