Last active
July 1, 2024 22:46
-
-
Save squeaky-nose/92e38e0af8770b4c79c5052995c9a484 to your computer and use it in GitHub Desktop.
XCUITest disable keyboard swipe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import XCTest | |
final class AppUITests: XCTestCase { | |
override func setUpWithError() throws { | |
SpringboardHelper.showKeyboardIfNeeded() | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import XCTest | |
class SpringboardHelper { | |
private static var keyboardDismissed = false | |
/// Call this from the setUp() function of any UI test that deals with the keyboard. | |
static func showKeyboardIfNeeded() { | |
if !keyboardDismissed { | |
let springBoard = XCUIApplication(bundleIdentifier: "com.apple.springboard") | |
springBoard.activate() | |
springBoard.windows.firstMatch.swipeDown(velocity: .slow) | |
springBoard.windows.firstMatch.tap() | |
springBoard.windows.firstMatch.swipeUp(velocity: .slow) | |
keyboardDismissed = true | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for reply! I got it that there might be search results. If I find any issues, I'll let you know 🙏