XCUIElement+Helpers.swift 1.0 KB

1234567891011121314151617181920212223242526272829303132
  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. XCTContext.runActivity(named: "Enter \"\(text)\" into Textfield") { _ in
  17. guard let stringValue = self.value as? String else {
  18. XCTFail("Tried to clear and enter text into a non string value")
  19. return
  20. }
  21. tap()
  22. let deleteString = stringValue.map { _ in XCUIKeyboardKey.delete.rawValue }.joined(separator: "")
  23. typeText(deleteString)
  24. typeText(text)
  25. }
  26. }
  27. }