Created
August 26, 2024 13:25
-
-
Save xsscx/7bb6ca9afa1966eba51beb0013cfe505 to your computer and use it in GitHub Desktop.
Test to reproduce crash in the Preferences app when entering a specific string in the search field.
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 CSSearchQuery_UITests: XCTestCase { | |
// MARK: - Test Methods | |
/// Test to reproduce crash in the Preferences app when entering a specific string in the search field. | |
func testPreferencesSearchCrash() throws { | |
// Initialize the Preferences app | |
let app = XCUIApplication(bundleIdentifier: "com.apple.Preferences") | |
app.launch() | |
// Wait for the initial screen to load | |
XCTAssertTrue(app.waitForExistence(timeout: 10), "Failed to launch the Preferences app within the expected time.") | |
// Swipe down to expose the search field | |
let firstElement = app.otherElements.firstMatch | |
firstElement.swipeDown() | |
// Locate the search field after the swipe gesture | |
let searchField = app.searchFields.firstMatch | |
let exists = searchField.waitForExistence(timeout: 10) | |
// MARK: - Debugging | |
// If the search field exists, attempt to type the crash-inducing input | |
if exists { | |
searchField.tap() | |
searchField.typeText("\"\":a") // Adjust this pattern as needed to trigger the crash | |
} else { | |
XCTFail("Search field not found or not accessible.") | |
// Debugging: Output the entire UI hierarchy for inspection | |
print(app.debugDescription) | |
} | |
} | |
// MARK: - Helper Methods | |
/// Helper method to log additional information when debugging. | |
private func logDebugInfo(for app: XCUIApplication) { | |
// Print the UI hierarchy to help identify issues with element visibility or accessibility | |
print(app.debugDescription) | |
// Additional debugging information can be logged here if needed | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Crash