Files
element-x-ios/ElementX/Sources/Other/Extensions/XCUIElement.swift
T
Stefan Ceriu 664e87fe87 Switch license to AGPL (#3237)
* Switch license file to AGPL

* Update file copyright headers

* Update the default project file header
2024-09-06 16:34:30 +03:00

32 lines
828 B
Swift

//
// Copyright 2022-2024 New Vector Ltd.
//
// SPDX-License-Identifier: AGPL-3.0-only
// Please see LICENSE in the repository root for full details.
//
import XCTest
extension XCUIElement {
func clearAndTypeText(_ text: String) {
forceTap()
guard let currentValue = value as? String else {
XCTFail("Tried to clear and type text into a non string value")
return
}
let deleteString = String(repeating: XCUIKeyboardKey.delete.rawValue, count: currentValue.count)
typeText(deleteString)
for character in text {
typeText(String(character))
}
}
func forceTap() {
let coordinate: XCUICoordinate = coordinate(withNormalizedOffset: .init(dx: 0.5, dy: 0.5))
coordinate.tap()
}
}