From 4eee26ba7c301cd6458e7884a0fc1885ce869790 Mon Sep 17 00:00:00 2001 From: agrim0312 Date: Sun, 12 Jul 2026 11:05:15 +0530 Subject: [PATCH] fix: lock screen via IOHID Power press on iOS 27 --- WebDriverAgentLib/Categories/XCUIDevice+FBHelpers.m | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/WebDriverAgentLib/Categories/XCUIDevice+FBHelpers.m b/WebDriverAgentLib/Categories/XCUIDevice+FBHelpers.m index 0b5d0f0b1..b877f4f7c 100644 --- a/WebDriverAgentLib/Categories/XCUIDevice+FBHelpers.m +++ b/WebDriverAgentLib/Categories/XCUIDevice+FBHelpers.m @@ -123,7 +123,17 @@ - (BOOL)fb_lockScreen:(NSError **)error if (fb_isLocked) { return YES; } - [self pressLockButton]; + if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"27.0")) { + // iOS 27: pressLockButton no longer locks; use a direct IOHID Power press (0x0C/0x30, ~0.5s hold). + if (![self fb_performIOHIDEventWithPage:0x0C + usage:0x30 + duration:0.5 + error:error]) { + return NO; + } + } else { + [self pressLockButton]; + } return [[[[FBRunLoopSpinner new] timeout:FBScreenLockTimeout] timeoutErrorMessage:@"Timed out while waiting until the screen gets locked"]