mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Ask the iPad to reveal the keyboard in UI Tests when it's hidden. (#3389)
This commit is contained in:
@@ -8,9 +8,11 @@
|
||||
import XCTest
|
||||
|
||||
extension XCUIElement {
|
||||
func clearAndTypeText(_ text: String) {
|
||||
func clearAndTypeText(_ text: String, app: XCUIApplication) {
|
||||
tapCenter()
|
||||
|
||||
app.showKeyboardIfNeeded()
|
||||
|
||||
guard let currentValue = value as? String else {
|
||||
XCTFail("Tried to clear and type text into a non string value")
|
||||
return
|
||||
@@ -29,3 +31,17 @@ extension XCUIElement {
|
||||
coordinate.tap()
|
||||
}
|
||||
}
|
||||
|
||||
extension XCUIApplication {
|
||||
/// Ensures the software keyboard is shown on an iPad when a text field is focussed.
|
||||
///
|
||||
/// Note: Whilst this could be added on XCUIElement to more closely tie it to a text field, it requires the
|
||||
/// app instance anyway, and some of our tests assert that a default focus has been set on the text field,
|
||||
/// so having a method that would set the focus and show the keyboard isn't always desirable.
|
||||
func showKeyboardIfNeeded() {
|
||||
if UIDevice.current.userInterfaceIdiom == .pad, keyboards.count == 0 {
|
||||
buttons["Keyboard"].tap()
|
||||
buttons["Show Keyboard"].tap()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user