Skip to content

Instantly share code, notes, and snippets.

@thecb4
Created January 2, 2019 21:13
Show Gist options
  • Save thecb4/dc819ea06a7bb780b99c0ab44e76a76a to your computer and use it in GitHub Desktop.
Save thecb4/dc819ea06a7bb780b99c0ab44e76a76a to your computer and use it in GitHub Desktop.
Extend XCUIApplication with Application protocol
extension XCUIApplication: Application {
static var app: Application {
return XCUIApplication()
}
var movieTable: UIElement {
return self.tables.staticTexts["New Releases"]
}
var searchBar: UIElement {
return self.searchFields["Such sights to show you..."]
}
func movie(titled: String) -> UIElement {
let predicate = NSPredicate(format: "label CONTAINS[c] %@", titled)
return self.tables.staticTexts.containing(predicate).firstMatch as UIElement
}
func moviePoster(titled: String) -> UIElement {
return self.tables.staticTexts[titled]
}
func comments(containing text: String) -> [UIElement] {
let predicate = NSPredicate(format: "value CONTAINS[c] %@", text)
let textViews = self.tables.cells.textViews
let elementQuery = textViews.containing(predicate)
print(elementQuery.allElementsBoundByIndex.count)
return elementQuery.allElementsBoundByIndex
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment