Guest User

Untitled

a guest
Feb 24th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. extension XCUIElement {
  2. /**
  3. Removes any current text in the field before typing in the new value
  4. - Parameter text: the text to enter into the field
  5. */
  6. func clearAndEnterText(text: String) {
  7. defer {
  8. self.typeText(text)
  9. }
  10.  
  11. guard let stringValue = self.value as? String else {
  12. return
  13. }
  14.  
  15. self.tap()
  16.  
  17. let deleteString = stringValue.flatMap { _ in XCUIKeyboardKey.delete.rawValue }.joined()
  18. self.typeText(deleteString)
  19. }
  20. }
Add Comment
Please, Sign In to add comment