Skip to content

Instantly share code, notes, and snippets.

@olbrichj
Created October 17, 2017 14:45
Show Gist options
  • Save olbrichj/e833125681d8cfe08c90ab82ec5464b5 to your computer and use it in GitHub Desktop.
Save olbrichj/e833125681d8cfe08c90ab82ec5464b5 to your computer and use it in GitHub Desktop.
extension XCUIElement {
func write(string: String) {
guard let stringValue = self.value as? String else {
XCTFail("Tried to clear and enter text into a non string value")
return
}
self.tap()
// clear element before writing new text
let deleteString = stringValue.characters.map { _ in XCUIKeyboardKeyDelete }.joined(separator: "")
self.typeText(deleteString)
self.typeText(string)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment