From a27eb39b9150af8510b43f0cdba67baec6d47a5d Mon Sep 17 00:00:00 2001 From: Mykola Mokhnach Date: Thu, 17 Jul 2025 12:04:04 +0200 Subject: [PATCH 1/2] chore: Remove the redundant check after activating the system app --- .../Categories/XCUIApplication+FBHelpers.m | 14 ++++---------- WebDriverAgentLib/Utilities/FBScreenshot.m | 2 +- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/WebDriverAgentLib/Categories/XCUIApplication+FBHelpers.m b/WebDriverAgentLib/Categories/XCUIApplication+FBHelpers.m index a2875a165..804aaff8c 100644 --- a/WebDriverAgentLib/Categories/XCUIApplication+FBHelpers.m +++ b/WebDriverAgentLib/Categories/XCUIApplication+FBHelpers.m @@ -621,23 +621,17 @@ + (BOOL)fb_switchToSystemApplicationWithError:(NSError **)error { XCUIApplication *systemApp = self.fb_systemApplication; @try { - if (!systemApp.running) { - [systemApp launch]; - } else { + if (systemApp.running) { [systemApp activate]; + } else { + [systemApp launch]; } } @catch (NSException *e) { return [[[FBErrorBuilder alloc] withDescription:nil == e ? @"Cannot open the home screen" : e.reason] buildError:error]; } - return [[[[FBRunLoopSpinner new] - timeout:5] - timeoutErrorMessage:@"Timeout waiting until the home screen is visible"] - spinUntilTrue:^BOOL{ - return [systemApp fb_isSameAppAs:self.fb_activeApplication]; - } - error:error]; + return YES; } - (BOOL)fb_isSameAppAs:(nullable XCUIApplication *)otherApp diff --git a/WebDriverAgentLib/Utilities/FBScreenshot.m b/WebDriverAgentLib/Utilities/FBScreenshot.m index 3d9716dea..d35078f1e 100644 --- a/WebDriverAgentLib/Utilities/FBScreenshot.m +++ b/WebDriverAgentLib/Utilities/FBScreenshot.m @@ -28,7 +28,7 @@ NSString *formatTimeInterval(NSTimeInterval interval) { NSUInteger milliseconds = (NSUInteger)(interval * 1000); - return [NSString stringWithFormat:@"%ld ms", milliseconds]; + return [NSString stringWithFormat:@"%lu ms", milliseconds]; } @implementation FBScreenshot From ec7dd61185791d2bfcfef347eaa5f93788001e56 Mon Sep 17 00:00:00 2001 From: Mykola Mokhnach Date: Thu, 17 Jul 2025 17:49:19 +0200 Subject: [PATCH 2/2] Update tests --- WebDriverAgentTests/IntegrationTests/XCUIDeviceHelperTests.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WebDriverAgentTests/IntegrationTests/XCUIDeviceHelperTests.m b/WebDriverAgentTests/IntegrationTests/XCUIDeviceHelperTests.m index 548bd70a5..52ab069a1 100644 --- a/WebDriverAgentTests/IntegrationTests/XCUIDeviceHelperTests.m +++ b/WebDriverAgentTests/IntegrationTests/XCUIDeviceHelperTests.m @@ -102,7 +102,7 @@ - (void)testGoToHomeScreen NSError *error; XCTAssertTrue([[XCUIDevice sharedDevice] fb_goToHomescreenWithError:&error]); XCTAssertNil(error); - XCTAssertTrue([XCUIApplication fb_activeApplication].icons[@"Safari"].exists); + FBAssertWaitTillBecomesTrue([XCUIApplication fb_activeApplication].icons[@"Safari"].exists); } - (void)testLockUnlockScreen