From a57fcbfd9a5f4108eb35d67abe699ef39021775d Mon Sep 17 00:00:00 2001 From: Ryan Jarvis Date: Tue, 12 Nov 2024 20:19:14 -0600 Subject: [PATCH] Capture map result on MainActor in elementCompoundOrPredicate --- Example/ExampleUITests/XCUITestCase.swift | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Example/ExampleUITests/XCUITestCase.swift b/Example/ExampleUITests/XCUITestCase.swift index 34dcef5..30c84b7 100644 --- a/Example/ExampleUITests/XCUITestCase.swift +++ b/Example/ExampleUITests/XCUITestCase.swift @@ -20,6 +20,7 @@ class XCUITestCase: XCTestCase { try app().descendants(matching: .any) } + @MainActor func elementPredicate(labeled label: String) -> NSPredicate { NSComparisonPredicate( leftExpression: NSExpression(forKeyPath: \XCUIElement.label), @@ -31,11 +32,14 @@ class XCUITestCase: XCTestCase { } func elementCompoundOrPredicate(labeled labels: Set) -> NSPredicate { - NSCompoundPredicate(orPredicateWithSubpredicates: labels.map(elementPredicate(labeled:))) + let subpredicates = labels.map { label in + elementPredicate(labeled: label) + } + return NSCompoundPredicate(orPredicateWithSubpredicates: subpredicates) } override func setUp() async throws { - DispatchQueue.main.async { + Task { @MainActor in self._app = XCUIApplication() self.continueAfterFailure = false try? self.app().launch()