tests completed

This commit is contained in:
Mauro Romito
2022-12-13 18:12:47 +01:00
parent bbf4bf3047
commit d679176137
5 changed files with 100 additions and 18 deletions
@@ -18,16 +18,21 @@ import Foundation
import XCTest
extension XCUIApplication {
func goToScreenWithIdentifier(_ identifier: String) {
func goToScreenWithIdentifier(_ identifier: String, shouldUseSlowTyping: Bool = false) {
// Search for the screen identifier
let textField = textFields["searchQueryTextField"]
let button = buttons[identifier]
// Sometimes the search gets stuck without showing any results. Try to nudge it along
for _ in 0...10 {
textField.clearAndTypeText(identifier)
if button.exists {
break
// This always fixes the stuck search issue, but makes the typing slower
if shouldUseSlowTyping {
textField.typeSlowly(identifier)
} else {
// Sometimes the search gets stuck without showing any results. Try to nudge it along
for _ in 0...10 {
textField.clearAndTypeText(identifier)
if button.exists {
break
}
}
}
@@ -35,7 +40,7 @@ extension XCUIApplication {
}
}
private extension XCUIElement {
extension XCUIElement {
func clearAndTypeText(_ text: String) {
guard let stringValue = value as? String else {
XCTFail("Tried to clear and type text into a non string value")
@@ -49,4 +54,9 @@ private extension XCUIElement {
typeText(deleteString)
typeText(text)
}
func typeSlowly(_ text: String) {
tap()
text.forEach{ typeText(String($0)) }
}
}