Created
June 1, 2018 14:13
-
-
Save evermeer/4969d7722541e7b244d6e511bb074381 to your computer and use it in GitHub Desktop.
code block 2 for UITest medium blog
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public extension RawRepresentable { | |
var element: XCUIElement { | |
if query.count > 1 { | |
fatalError("There are \(query.count) elements with identifier \(self.rawValue as? String ?? "") found!") | |
} | |
return query.firstMatch | |
} | |
var query: XCUIElementQuery { | |
return XCUIApplication().descendants(matching: .any).matching(identifier: self.rawValue as? String ?? "") | |
} | |
var count: Int { | |
return Int(query.count) | |
} | |
subscript(i: Int) -> XCUIElement { | |
return query.allElementsBoundByIndex[i] | |
} | |
var exists: Bool { | |
return element.exists | |
} | |
func tap() { | |
element.tap() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment