XCUIElement+Helpers.swift 922 B

12345678910111213141516171819202122232425262728293031
  1. /*****************************************************************************
  2. * XCUIElement+Helpers.swift
  3. * VLC for iOSUITests
  4. *****************************************************************************
  5. * Copyright (c) 2018 VideoLAN. All rights reserved.
  6. * $Id$
  7. *
  8. * Authors: Mike JS. Choi <mkchoi212 # icloud.com>
  9. *
  10. * Refer to the COPYING file of the official project for license.
  11. *****************************************************************************/
  12. import Foundation
  13. import XCTest
  14. extension XCUIElement {
  15. func clearAndEnter(text: String) {
  16. guard let stringValue = self.value as? String else {
  17. XCTFail("Tried to clear and enter text into a non string value")
  18. return
  19. }
  20. tap()
  21. let deleteString = stringValue.map { _ in XCUIKeyboardKey.delete.rawValue }.joined(separator: "")
  22. typeText(deleteString)
  23. typeText(text)
  24. }
  25. }