Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#appium #mac2-driver #macos #ui-automation #screen-recording #329

Open
tgz0514 opened this issue Feb 6, 2025 · 22 comments
Open

#appium #mac2-driver #macos #ui-automation #screen-recording #329

tgz0514 opened this issue Feb 6, 2025 · 22 comments

Comments

@tgz0514
Copy link

tgz0514 commented Feb 6, 2025

"When using Mac2 driver with Appium for Mac UI automation testing, there's a notification banner showing 'Automation Test Running' on the screen. This banner interferes with screen recording quality. Is there a way to disable or hide this notification banner during test execution?"

@mykola-mokhnach
Copy link
Contributor

I don't think it is possible to disable that banner as this is Apple's own security feature.
How do you record the screen during the test?

@Zz-vvi
Copy link

Zz-vvi commented Feb 6, 2025

I don't think it is possible to disable that banner as this is Apple's own security feature. How do you record the screen during the test?

ffmpeg / quicktimeplayer / screencapture

@mykola-mokhnach
Copy link
Contributor

mykola-mokhnach commented Feb 6, 2025

I've created another PR to enable screen recording over native APIs provided by XCTest itself. I believe screen recordings made via these APIs should not show the annoying overlay

@tgz0514
Copy link
Author

tgz0514 commented Feb 7, 2025

I've created another PR to enable screen recording over native APIs provided by XCTest itself. I believe screen recordings made via these APIs should not show the annoying overlay

Thank you for creating the PR for screen recording improvement. Having recordings without overlay would definitely enhance the user experience. Looking forward to trying out this native XCTest-based solution.

@mykola-mokhnach
Copy link
Contributor

The PR has been merged and published in the driver version 2.1.0

@tgz0514
Copy link
Author

tgz0514 commented Feb 8, 2025

The PR has been merged and published in the driver version 2.1.0
I used it as described, but it gave an error. Why?

driver.execute_script('macos: listDisplays')
{'1': {'id': 1, 'isMain': True}, '2': {'id': 2, 'isMain': False}, '3': {'id': 3, 'isMain': False}}

driver.execute_script('macos: startNativeScreenRecording',{'displayId':1})
{'uuid': 'DBF9B67F-7180-441A-B45C-CD6CB18C96CD', 'startedAt': 1738988129.5143409, 'fps': 24, 'codec': 0, 'displayId': 1}

driver.execute_script('macos: getNativeScreenRecordingInfo')
{'uuid': 'DBF9B67F-7180-441A-B45C-CD6CB18C96CD', 'startedAt': 1738988129.5143409, 'fps': 24, 'codec': 0, 'displayId': 1}

driver.execute_script('macos: stopNativeScreenRecording')
selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: The screen recording identified by DBF9B67F-7180-441A-B45C-CD6CB18C96CD has not been found. Is it accessible?
Stacktrace:
UnknownError: An unknown server-side error occurred while processing the command. Original error: The screen recording identified by DBF9B67F-7180-441A-B45C-CD6CB18C96CD has not been found. Is it accessible?
at getResponseForW3CError (/opt/homebrew/lib/node_modules/appium/node_modules/@appium/base-driver/lib/protocol/errors.js:1145:9)
at asyncHandler (/opt/homebrew/lib/node_modules/appium/node_modules/@appium/base-driver/lib/protocol/protocol.js:485:57)

I hope to add a parameter to save the recorded video directly to a location that can be specified by the test machine, such as /tmp/xx.mp4

@tgz0514
Copy link
Author

tgz0514 commented Feb 8, 2025

2025-02-08 12:16:11:629 - [154d3af1][Mac2Driver@5d3b] Encountered internal error running command: Error: The screen recording identified by DBF9B67F-7180-441A-B45C-CD6CB18C96CD has not been found. Is it accessible?
at Mac2Driver.macosStopNativeScreenRecording (.appium/node_modules/appium-mac2-driver/lib/commands/native-record-screen.ts:97:11
at Mac2Driver.executeMethod (/opt/homebrew/lib/node_modules/appium/node_modules/@appium/base-driver/lib/basedriver/commands/execute.ts:36:12)
at Mac2Driver.execute (.appium/node_modules/appium-mac2-driver/lib/commands/execute.js:16:10)
2025-02-08 12:16:11:630 - [154d3af1][HTTP] <-- POST /session/154d3af1-3eea-4475-8f23-1cad58269d9d/execute/sync 500 157 ms - 724

@mykola-mokhnach
Copy link
Contributor

mykola-mokhnach commented Feb 8, 2025

How do you execute your appium server? If from Terminal then make sure it has the "Full Disk Access" permission enabled in System Preferences -> Privacy & Security tab

@mykola-mokhnach
Copy link
Contributor

mykola-mokhnach commented Feb 8, 2025

Also make sure the appropriate screen recording is present on the local file system by executing the following command: find "$HOME/Library/Daemon Containers/" -type f -name "DBF9B67F-7180-441A-B45C-CD6CB18C96CD"

@mykola-mokhnach
Copy link
Contributor

mykola-mokhnach commented Feb 8, 2025

I've added an explicit comment about this requirement to the docs and improved the exception message: #331

@tgz0514
Copy link
Author

tgz0514 commented Feb 8, 2025

How do you execute your appium server? If from Terminal then make sure it has the "Full Disk Access" permission enabled in System Preferences -> Privacy & Security tab

It is true.

However, after calling stopNativeScreenRecording, calling startNativeScreenRecording again will result in an error,getNativeScreenRecordingInfo return none.

UnknownError: An unknown server-side error occurred while processing the command. Original error: Error Domain=XCTDaemon.ScreenRecordingError Code=0 "Already recording, there can only be one screen recording at a time." UserInfo={NSLocalizedFailure=Failed to start screen recording., NSLocalizedFailureReason=Already recording, there can only be one screen recording at a time., NSLocalizedRecoverySuggestion=Stop the currently active screen recording first and try again.}
at errorFromW3CJsonCode (/opt/homebrew/lib/node_modules/appium/node_modules/@appium/base-driver/lib/protocol/errors.js:1112:25)
at ProxyRequestError.getActualError (/opt/homebrew/lib/node_modules/appium/node_modules/@appium/base-driver/lib/protocol/errors.js:981:14)
at WDAMacProxy.command (/opt/homebrew/lib/node_modules/appium/node_modules/@appium/base-driver/lib/jsonwp-proxy/proxy.js:348:19)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at Mac2Driver.macosStartNativeScreenRecording (/Users/tangguangzhe/.appium/node_modules/appium-mac2-driver/lib/commands/native-record-screen.ts:29:18)
at Mac2Driver.executeMethod (/opt/homebrew/lib/node_modules/appium/node_modules/@appium/base-driver/lib/basedriver/commands/execute.ts:36:12)
at Mac2Driver.execute (.appium/node_modules/appium-mac2-driver/lib/commands/execute.js:16:10)

➜ Daemon Containers ls
01B799CB-97FA-4167-960D-BEB3C35164C6 A06A5FE3-DD9C-4F90-81E3-1BD3FBB1132C
4AEC0CD8-C56A-485E-AA9B-67B4AE983F5F DB8DE649-00FD-49CE-B6E9-37EFB5E4FCFB
6D67C033-2E42-454D-8249-40AD9B60EE9A F1C1D5EF-E325-4F88-87B4-DA651B7E6631
7E1F2934-56B6-4573-8866-FCEF5B4DA679 FC972D55-D5D0-4081-9EA7-1ADA396A8A12

➜ Daemon Containers rm -rf *

startNativeScreenRecording
UnknownError: An unknown server-side error occurred while processing the command. Original error: Error Domain=XCTDaemon.ScreenRecordingError Code=7 "Failed to write file." UserInfo={NSLocalizedFailure=Failed to start screen recording., NSLocalizedFailureReason=Failed to write file., NSLocalizedRecoverySuggestion=Make sure there's enough space on the device.}
The device has sufficient disk space

@mykola-mokhnach
Copy link
Contributor

startNativeScreenRecording

UnknownError: An unknown server-side error occurred while processing the command. Original error: Error Domain=XCTDaemon.ScreenRecordingError Code=7 "Failed to write file." UserInfo={NSLocalizedFailure=Failed to start screen recording., NSLocalizedFailureReason=Failed to write file., NSLocalizedRecoverySuggestion=Make sure there's enough space on the device.}
The device has sufficient disk space

This might be a valid error. Recorded videos are usually quite large and need lots of space, so be careful about the amount of space left on the home partition

@mykola-mokhnach
Copy link
Contributor

UnknownError: An unknown server-side error occurred while processing the command. Original error: Error Domain=XCTDaemon.ScreenRecordingError Code=0 "Already recording, there can only be one screen recording at a time." UserInfo={NSLocalizedFailure=Failed to start screen recording., NSLocalizedFailureReason=Already recording, there can only be one screen recording at a time., NSLocalizedRecoverySuggestion=Stop the currently active screen recording first and try again.}

Please provide a proper issue report for this one including the full server log and the client code example which reproduces it.

@tgz0514
Copy link
Author

tgz0514 commented Feb 8, 2025

UnknownError: An unknown server-side error occurred while processing the command. Original error: Error Domain=XCTDaemon.ScreenRecordingError Code=0 "Already recording, there can only be one screen recording at a time." UserInfo={NSLocalizedFailure=Failed to start screen recording., NSLocalizedFailureReason=Already recording, there can only be one screen recording at a time., NSLocalizedRecoverySuggestion=Stop the currently active screen recording first and try again.}

Please provide a proper issue report for this one including the full server log and the client code example which reproduces it.

Description

After completing one full recording cycle (start -> get info -> stop), attempting to start a new recording fails.

Steps to Reproduce

  1. Call startNativeScreenRecording ✅ (Success)
  2. Call getNativeScreenRecordingInfo ✅ (Success)
  3. Call stopNativeScreenRecording ✅ (Success)
  4. Call startNativeScreenRecording again ❌ (Fails)

code
`from appium import webdriver
from appium.options.common.base import AppiumOptions

options = AppiumOptions()
options.load_capabilities({
"platformName": "mac",
"appium:automationName": "mac2",
"appium:newCommandTimeout": 3600,
"appium:connectHardwareKeyboard": True
})

driver = webdriver.Remote('http://10.93.1.112:4723', options=options)

driver.execute_script('macos: startNativeScreenRecording')
driver.execute_script('macos: getNativeScreenRecordingInfo')
b_64 = driver.execute_script('macos: stopNativeScreenRecording')

driver.execute_script('macos: startNativeScreenRecording')`

appium server log

2025-02-08 19:25:46:595 - [b47a027a][HTTP] <-- POST /session/b47a027a-c14a-4fde-9991-6a457e4dfa9d/execute/sync 200 402 ms - 14168772
2025-02-08 19:35:15:770 - [b47a027a][HTTP] --> POST /session/b47a027a-c14a-4fde-9991-6a457e4dfa9d/execute/sync {"script":"macos: startNativeScreenRecording","args":[]}
2025-02-08 19:35:15:774 - [b47a027a][Mac2Driver@5eb1] Calling AppiumDriver.execute() with args: ["macos: startNativeScreenRecording",[],"b47a027a-c14a-4fde-9991-6a457e4dfa9d"]
2025-02-08 19:35:15:775 - [b47a027a][Mac2Driver@5eb1] Executing extension command 'macos: startNativeScreenRecording'
2025-02-08 19:35:15:797 - [b47a027a][WD Proxy] Proxying [POST /wda/video/start] to [POST http://127.0.0.1:10100/session/37DFABE5-D219-4162-BEBB-28846F749035/wda/video/start] with body: {}
2025-02-08 19:35:15:924 - [b47a027a][WD Proxy] Got response with status 500: {"value":{"error":"unknown error","message":"Error Domain=XCTDaemon.ScreenRecordingError Code=0 "Already recording, there can only be one screen recording at a time." UserInfo={NSLocalizedFailure=Failed to start screen recording., NSLocalizedFailureReason=Already recording, there can only be one screen recording at a time., NSLocalizedRecoverySuggestion=Stop the currently active screen recording first and try again.}","traceback":""},"sessionId":"37DFABE5-D219-4162-BEBB-28846F749035"}
2025-02-08 19:35:15:925 - [b47a027a][W3C] Matched W3C error code 'unknown error' to UnknownError
2025-02-08 19:35:15:935 - [b47a027a][Mac2Driver@5eb1] Encountered internal error running command: UnknownError: An unknown server-side error occurred while processing the command. Original error: Error Domain=XCTDaemon.ScreenRecordingError Code=0 "Already recording, there can only be one screen recording at a time." UserInfo={NSLocalizedFailure=Failed to start screen recording., NSLocalizedFailureReason=Already recording, there can only be one screen recording at a time., NSLocalizedRecoverySuggestion=Stop the currently active screen recording first and try again.}
at errorFromW3CJsonCode (/opt/homebrew/lib/node_modules/appium/node_modules/@appium/base-driver/lib/protocol/errors.js:1112:25)
at ProxyRequestError.getActualError (/opt/homebrew/lib/node_modules/appium/node_modules/@appium/base-driver/lib/protocol/errors.js:981:14)
at WDAMacProxy.command (/opt/homebrew/lib/node_modules/appium/node_modules/@appium/base-driver/lib/jsonwp-proxy/proxy.js:348:19)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at Mac2Driver.macosStartNativeScreenRecording (/Users/tangguangzhe/.appium/node_modules/appium-mac2-driver/lib/commands/native-record-screen.ts:29:18)
at Mac2Driver.executeMethod (/opt/homebrew/lib/node_modules/appium/node_modules/@appium/base-driver/lib/basedriver/commands/execute.ts:36:12)
at Mac2Driver.execute (.appium/node_modules/appium-mac2-driver/lib/commands/execute.js:16:10)
2025-02-08 19:35:15:938 - [b47a027a][HTTP] <-- POST /session/b47a027a-c14a-4fde-9991-6a457e4dfa9d/execute/sync 500 170 ms - 1908

@mykola-mokhnach
Copy link
Contributor

Unfortunately I cannot reproduce the above issue locally. Please provide the full log, including the output of the previous stopNativeScreenRecording method output. Also enable xcodebuild output in capabilities (showServerLogs: true)

@tgz0514
Copy link
Author

tgz0514 commented Feb 8, 2025

Unfortunately I cannot reproduce the above issue locally. Please provide the full log, including the output of the previous stopNativeScreenRecording method output. Also enable xcodebuild output in capabilities (showServerLogs: true)

2025-02-08 20:14:42:548 [Appium] Welcome to Appium v2.11.5 (REV b6fafba4864d65acabf966415e14b2dd86d81e1a)
2025-02-08 20:14:42:550 [Appium] Non-default server args:
2025-02-08 20:14:42:551 [Appium] {
allowCors: true,
localTimezone: true,
logTimestamp: true,
relaxedSecurityEnabled: true
}
2025-02-08 20:14:42:552 [Appium] The autodetected Appium home path: /Users/labtest/.appium
2025-02-08 20:14:42:552 [Appium] Attempting to load driver chromium...
2025-02-08 20:14:42:553 [Appium] Attempting to load driver xcuitest...
2025-02-08 20:14:42:553 [Appium] Attempting to load driver uiautomator2...
2025-02-08 20:14:42:554 [Appium] Requiring driver at /Users/labtest/.appium/node_modules/appium-chromium-driver/index.js
2025-02-08 20:14:42:557 [Appium] Requiring driver at /Users/labtest/.appium/node_modules/appium-xcuitest-driver/build/index.js
2025-02-08 20:14:42:558 [Appium] Requiring driver at /Users/labtest/.appium/node_modules/appium-uiautomator2-driver/build/index.js
2025-02-08 20:14:43:670 [Appium] ChromiumDriver has been successfully loaded in 1.117s
2025-02-08 20:14:43:670 [Appium] XCUITestDriver has been successfully loaded in 1.117s
2025-02-08 20:14:43:670 [Appium] AndroidUiautomator2Driver has been successfully loaded in 1.117s
2025-02-08 20:14:43:671 [Appium] Attempting to load driver safari...
2025-02-08 20:14:43:671 [Appium] Attempting to load driver mac2...
2025-02-08 20:14:43:672 [Appium] Requiring driver at /Users/labtest/.appium/node_modules/appium-mac2-driver/build/index.js
2025-02-08 20:14:43:740 [Appium] Mac2Driver has been successfully loaded in 0.069s
2025-02-08 20:14:43:741 [Appium] Requiring driver at /Users/labtest/.appium/node_modules/appium-safari-driver/build/index.js
2025-02-08 20:14:43:821 [Appium] SafariDriver has been successfully loaded in 0.150s
2025-02-08 20:14:43:829 [Appium] You have enabled CORS requests from any host. Be careful not to visit sites which could maliciously try to start Appium sessions on your machine
2025-02-08 20:14:43:831 [Appium] Appium REST http interface listener started on http://0.0.0.0:4723
2025-02-08 20:14:43:832 [Appium] You can provide the following URLs in your client code to connect to this server:
http://127.0.0.1:4723/ (only accessible from the same host)
http://10.90.0.176:4723/
http://10.93.1.112:4723/
http://10.251.1.1:4723/
2025-02-08 20:14:43:832 [Appium] Available drivers:
2025-02-08 20:14:43:832 [Appium] - chromium@1.3.29 (automationName 'Chromium')
2025-02-08 20:14:43:832 [Appium] - xcuitest@7.24.15 (automationName 'XCUITest')
2025-02-08 20:14:43:832 [Appium] - uiautomator2@3.7.7 (automationName 'UiAutomator2')
2025-02-08 20:14:43:832 [Appium] - safari@3.5.17 (automationName 'Safari')
2025-02-08 20:14:43:832 [Appium] - mac2@2.1.0 (automationName 'Mac2')
2025-02-08 20:14:43:832 [Appium] Available plugins:
2025-02-08 20:14:43:832 [Appium] - execute-driver@3.0.36
2025-02-08 20:14:43:832 [Appium] - images@3.0.21
2025-02-08 20:14:43:832 [Appium] No plugins activated. Use the --use-plugins flag with names of plugins to activate
2025-02-08 20:14:58:356 [HTTP] Request idempotency key: ef6e360c-939c-40f3-8ac8-105db1adcee5
2025-02-08 20:14:58:373 [HTTP] --> POST /session {"capabilities":{"firstMatch":[{}],"alwaysMatch":{"platformName":"mac","appium:automationName":"mac2","appium:newCommandTimeout":3600,"appium:connectHardwareKeyboard":true,"appium:showServerLogs":true}}}
2025-02-08 20:14:58:374 [AppiumDriver@40dc] Calling AppiumDriver.createSession() with args: [null,null,{"firstMatch":[{}],"alwaysMatch":{"platformName":"mac","appium:automationName":"mac2","appium:newCommandTimeout":3600,"appium:connectHardwareKeyboard":true,"appium:showServerLogs":true}}]
2025-02-08 20:14:58:374 [AppiumDriver@40dc] Event 'newSessionRequested' logged at 1739016898374 (20:14:58 GMT+0800 (中国标准时间))
2025-02-08 20:14:58:376 [Appium] Attempting to find matching driver for automationName 'mac2' and platformName 'mac'
2025-02-08 20:14:58:376 [Appium] The 'mac2' driver was installed and matched caps.
2025-02-08 20:14:58:376 [Appium] Will require it at /Users/labtest/.appium/node_modules/appium-mac2-driver
2025-02-08 20:14:58:377 [Appium] Requiring driver at /Users/labtest/.appium/node_modules/appium-mac2-driver/build/index.js
2025-02-08 20:14:58:377 [AppiumDriver@40dc] Appium v2.11.5 creating new Mac2Driver (v2.1.0) session
2025-02-08 20:14:58:377 [AppiumDriver@40dc] Checking BaseDriver versions for Appium and Mac2Driver
2025-02-08 20:14:58:377 [AppiumDriver@40dc] Appium's BaseDriver version is 9.11.5
2025-02-08 20:14:58:377 [AppiumDriver@40dc] Mac2Driver's BaseDriver version is 9.11.5
2025-02-08 20:14:58:378 [AppiumDriver@40dc] Applying relaxed security to 'Mac2Driver' as per server command line argument. All insecure features will be enabled unless explicitly disabled by --deny-insecure
2025-02-08 20:14:58:378 [Mac2Driver@e0f7]
2025-02-08 20:14:58:378 [Mac2Driver@e0f7] Creating session with W3C capabilities: {
"alwaysMatch": {
"platformName": "mac",
"appium:automationName": "mac2",
"appium:newCommandTimeout": 3600,
"appium:connectHardwareKeyboard": true,
"appium:showServerLogs": true
},
"firstMatch": [
{}
]
}
2025-02-08 20:14:58:380 [Mac2Driver@e0f7] The following provided capabilities were not recognized by this driver:
2025-02-08 20:14:58:380 [Mac2Driver@e0f7] connectHardwareKeyboard
2025-02-08 20:14:58:380 [1c5a3a6c][Mac2Driver@e0f7] Session created with session id: 1c5a3a6c-c3a0-4cfb-ab36-e43b66e62d92
2025-02-08 20:14:58:380 [1c5a3a6c][WebDriverAgentMac] Using bootstrap root: /Users/labtest/.appium/node_modules/appium-mac2-driver/WebDriverAgentMac
2025-02-08 20:14:58:382 [1c5a3a6c][WebDriverAgentMac] Using xcodebuild binary at '/usr/bin/xcodebuild'
2025-02-08 20:14:58:383 [1c5a3a6c][WebDriverAgentMac] There is no need to perform the project cleanup. A fresh install has been detected
2025-02-08 20:14:58:384 [1c5a3a6c][WebDriverAgentMac] Using 127.0.0.1 as server host
2025-02-08 20:14:58:384 [1c5a3a6c][WebDriverAgentMac] Using port 10100
2025-02-08 20:14:58:386 [1c5a3a6c][WebDriverAgentMac] Starting Mac2Driver host process: xcodebuild build-for-testing test-without-building -project /Users/labtest/.appium/node_modules/appium-mac2-driver/WebDriverAgentMac/WebDriverAgentMac.xcodeproj -scheme WebDriverAgentRunner COMPILER_INDEX_STORE_ENABLE=NO
2025-02-08 20:14:58:390 [1c5a3a6c][WD Proxy] Matched '/status' to command name 'getStatus'
2025-02-08 20:14:58:391 [1c5a3a6c][WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:10100/status] with no body
2025-02-08 20:14:58:429 [1c5a3a6c][WD Proxy] connect ECONNREFUSED 127.0.0.1:10100
2025-02-08 20:14:59:431 [1c5a3a6c][WD Proxy] Matched '/status' to command name 'getStatus'
2025-02-08 20:14:59:432 [1c5a3a6c][WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:10100/status] with no body
2025-02-08 20:14:59:433 [1c5a3a6c][WD Proxy] connect ECONNREFUSED 127.0.0.1:10100
2025-02-08 20:14:59:894 [1c5a3a6c][WebDriverAgentMac] [xcodebuild] Command line invocation:
2025-02-08 20:14:59:895 [1c5a3a6c][WebDriverAgentMac] [xcodebuild] /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild build-for-testing test-without-building -project /Users/labtest/.appium/node_modules/appium-mac2-driver/WebDriverAgentMac/WebDriverAgentMac.xcodeproj -scheme WebDriverAgentRunner COMPILER_INDEX_STORE_ENABLE=NO

User defaults from command line:
IDEPackageSupportUseBuiltinSCM = YES

Build settings from command line:
COMPILER_INDEX_STORE_ENABLE = NO
2025-02-08 20:15:00:168 [1c5a3a6c][WebDriverAgentMac] [xcodebuild] --- xcodebuild: WARNING: Using the first of multiple matching destinations:
{ platform:macOS, arch:arm64, id:00006020-0006303A0E47C01E, name:My Mac }
{ platform:macOS, arch:x86_64, id:00006020-0006303A0E47C01E, name:My Mac }
{ platform:macOS, name:Any Mac }
2025-02-08 20:15:00:189 [1c5a3a6c][WebDriverAgentMac] [xcodebuild] Prepare packages
2025-02-08 20:15:00:409 [1c5a3a6c][WebDriverAgentMac] [xcodebuild] ComputeTargetDependencyGraph
2025-02-08 20:15:00:431 [1c5a3a6c][WebDriverAgentMac] [xcodebuild] note: Building targets in dependency order
2025-02-08 20:15:00:431 [1c5a3a6c][WebDriverAgentMac] [xcodebuild] note: Target dependency graph (2 targets)
Target 'WebDriverAgentRunner' in project 'WebDriverAgentMac'
➜ Explicit dependency on target 'WebDriverAgentLib' in project 'WebDriverAgentMac'
Target 'WebDriverAgentLib' in project 'WebDriverAgentMac' (no dependencies)
2025-02-08 20:15:00:431 [1c5a3a6c][WebDriverAgentMac] [xcodebuild] GatherProvisioningInputs
2025-02-08 20:15:00:433 [1c5a3a6c][WD Proxy] Matched '/status' to command name 'getStatus'
2025-02-08 20:15:00:433 [1c5a3a6c][WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:10100/status] with no body
2025-02-08 20:15:00:434 [1c5a3a6c][WD Proxy] connect ECONNREFUSED 127.0.0.1:10100
2025-02-08 20:15:00:446 [1c5a3a6c][WebDriverAgentMac] [xcodebuild] CreateBuildDescription
2025-02-08 20:15:00:478 [1c5a3a6c][WebDriverAgentMac] [xcodebuild] ClangStatCache /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang-stat-cache /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk /Users/labtest/Library/Developer/Xcode/DerivedData/SDKStatCaches.noindex/macosx14.4-23E208-13f6e737bddbb37f317b3579f3535bf5.sdkstatcache
cd /Users/labtest/.appium/node_modules/appium-mac2-driver/WebDriverAgentMac/WebDriverAgentMac.xcodeproj
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang-stat-cache /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk -o /Users/labtest/Library/Developer/Xcode/DerivedData/SDKStatCaches.noindex/macosx14.4-23E208-13f6e737bddbb37f317b3579f3535bf5.sdkstatcache
2025-02-08 20:15:00:548 [1c5a3a6c][WebDriverAgentMac] [xcodebuild] ** TEST BUILD SUCCEEDED **
2025-02-08 20:15:00:549 [1c5a3a6c][WebDriverAgentMac] [xcodebuild] --- xcodebuild: WARNING: Using the first of multiple matching destinations:
{ platform:macOS, arch:arm64, id:00006020-0006303A0E47C01E, name:My Mac }
{ platform:macOS, arch:x86_64, id:00006020-0006303A0E47C01E, name:My Mac }
{ platform:macOS, name:Any Mac }
2025-02-08 20:15:01:436 [1c5a3a6c][WD Proxy] Matched '/status' to command name 'getStatus'
2025-02-08 20:15:01:436 [1c5a3a6c][WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:10100/status] with no body
2025-02-08 20:15:01:437 [1c5a3a6c][WD Proxy] connect ECONNREFUSED 127.0.0.1:10100
2025-02-08 20:15:01:999 [1c5a3a6c][WebDriverAgentMac] [xcodebuild] 2025-02-08 20:15:01.996295+0800 WebDriverAgentRunner-Runner[5177:94026] [Default] Running tests...
2025-02-08 20:15:02:194 [1c5a3a6c][WebDriverAgentMac] [xcodebuild] Test Suite 'All tests' started at 2025-02-08 20:15:02.193.
Test Suite 'WebDriverAgentRunner.xctest' started at 2025-02-08 20:15:02.193.
Test Suite 'UITestingUITests' started at 2025-02-08 20:15:02.193.
t = nans Suite Set Up
2025-02-08 20:15:02:197 [1c5a3a6c][WebDriverAgentMac] [xcodebuild] Test Case '-[UITestingUITests testRunner]' started.
2025-02-08 20:15:02:198 [1c5a3a6c][WebDriverAgentMac] [xcodebuild] t = 0.00s Start Test at 2025-02-08 20:15:02.194
2025-02-08 20:15:02:222 [1c5a3a6c][WebDriverAgentMac] [xcodebuild] t = 0.03s Set Up
2025-02-08 20:15:02:222 [1c5a3a6c][WebDriverAgentMac] [xcodebuild] 2025-02-08 20:15:02.222345+0800 WebDriverAgentRunner-Runner[5177:94026] Built at Feb 8 2025 11:41:16
2025-02-08 20:15:02:234 [1c5a3a6c][WebDriverAgentMac] [xcodebuild] 2025-02-08 20:15:02.232893+0800 WebDriverAgentRunner-Runner[5177:94026] ServerURLHere->http://localhost:10100<-ServerURLHere
2025-02-08 20:15:02:439 [1c5a3a6c][WD Proxy] Matched '/status' to command name 'getStatus'
2025-02-08 20:15:02:445 [1c5a3a6c][WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:10100/status] with no body
2025-02-08 20:15:02:459 [1c5a3a6c][WD Proxy] Got response with status 200: {"value":{"message":"WebDriverAgent is ready to accept commands","state":"success","os":{"version":"版本14.4(版号23E214)"},"ready":true,"build":{"time":"Feb 8 2025 11:41:16"}},"sessionId":null}
2025-02-08 20:15:02:556 [1c5a3a6c][WebDriverAgentMac] The host process is ready within 4167ms
2025-02-08 20:15:02:557 [1c5a3a6c][WD Proxy] Matched '/session' to command name 'createSession'
2025-02-08 20:15:02:557 [1c5a3a6c][WD Proxy] Proxying [POST /session] to [POST http://127.0.0.1:10100/session] with body: {"capabilities":{"firstMatch":[{}],"alwaysMatch":{"platformName":"mac","automationName":"mac2","newCommandTimeout":3600,"connectHardwareKeyboard":true,"showServerLogs":true}}}
2025-02-08 20:15:02:576 [1c5a3a6c][WD Proxy] Got response with status 200: {"value":{"sessionId":"740045F3-6F21-4E04-8AC2-89D314CE762F","capabilities":{"CFBundleIdentifier":"com.apple.finder"}},"sessionId":"740045F3-6F21-4E04-8AC2-89D314CE762F"}
2025-02-08 20:15:02:576 [1c5a3a6c][WD Proxy] Determined the downstream protocol as 'W3C'
2025-02-08 20:15:02:576 [1c5a3a6c][AppiumDriver@40dc] New Mac2Driver session created successfully, session 1c5a3a6c-c3a0-4cfb-ab36-e43b66e62d92 added to master session list
2025-02-08 20:15:02:576 [1c5a3a6c][AppiumDriver@40dc] Event 'newSessionStarted' logged at 1739016902576 (20:15:02 GMT+0800 (中国标准时间))
2025-02-08 20:15:02:576 [1c5a3a6c][Mac2Driver@e0f7] Cached the protocol value 'W3C' for the new session 1c5a3a6c-c3a0-4cfb-ab36-e43b66e62d92
2025-02-08 20:15:02:576 [1c5a3a6c][Mac2Driver@e0f7] Responding to client with driver.createSession() result: {"capabilities":{"platformName":"mac","automationName":"mac2","newCommandTimeout":3600,"connectHardwareKeyboard":true,"showServerLogs":true}}
2025-02-08 20:15:02:578 [1c5a3a6c][HTTP] <-- POST /session 200 4205 ms - 202
2025-02-08 20:15:02:585 [1c5a3a6c][HTTP] --> POST /session/1c5a3a6c-c3a0-4cfb-ab36-e43b66e62d92/execute/sync {"script":"macos: startNativeScreenRecording","args":[]}
2025-02-08 20:15:02:589 [1c5a3a6c][Mac2Driver@e0f7] Calling AppiumDriver.execute() with args: ["macos: startNativeScreenRecording",[],"1c5a3a6c-c3a0-4cfb-ab36-e43b66e62d92"]
2025-02-08 20:15:02:589 [1c5a3a6c][Mac2Driver@e0f7] Executing extension command 'macos: startNativeScreenRecording'
2025-02-08 20:15:02:599 [1c5a3a6c][WD Proxy] Proxying [POST /wda/video/start] to [POST http://127.0.0.1:10100/session/740045F3-6F21-4E04-8AC2-89D314CE762F/wda/video/start] with body: {}
2025-02-08 20:15:03:020 [1c5a3a6c][WD Proxy] Got response with status 200: {"value":{"uuid":"EFEAE31F-C055-4699-89D0-A983644A6D4B","startedAt":1739016903.0187821,"fps":24,"codec":0,"displayId":1},"sessionId":"740045F3-6F21-4E04-8AC2-89D314CE762F"}
2025-02-08 20:15:03:021 [1c5a3a6c][Mac2Driver@e0f7] Responding to client with driver.execute() result: {"uuid":"EFEAE31F-C055-4699-89D0-A983644A6D4B","startedAt":1739016903.0187821,"fps":24,"codec":0,"displayId":1}
2025-02-08 20:15:03:023 [1c5a3a6c][HTTP] <-- POST /session/1c5a3a6c-c3a0-4cfb-ab36-e43b66e62d92/execute/sync 200 437 ms - 121
2025-02-08 20:15:15:994 [1c5a3a6c][HTTP] --> POST /session/1c5a3a6c-c3a0-4cfb-ab36-e43b66e62d92/execute/sync {"script":"macos: getNativeScreenRecordingInfo","args":[]}
2025-02-08 20:15:16:010 [1c5a3a6c][Mac2Driver@e0f7] Calling AppiumDriver.execute() with args: ["macos: getNativeScreenRecordingInfo",[],"1c5a3a6c-c3a0-4cfb-ab36-e43b66e62d92"]
2025-02-08 20:15:16:011 [1c5a3a6c][Mac2Driver@e0f7] Executing extension command 'macos: getNativeScreenRecordingInfo'
2025-02-08 20:15:16:035 [1c5a3a6c][WD Proxy] Proxying [GET /wda/video] to [GET http://127.0.0.1:10100/session/740045F3-6F21-4E04-8AC2-89D314CE762F/wda/video] with no body
2025-02-08 20:15:16:040 [1c5a3a6c][WD Proxy] Got response with status 200: {"value":{"uuid":"EFEAE31F-C055-4699-89D0-A983644A6D4B","startedAt":1739016903.0187821,"fps":24,"codec":0,"displayId":1},"sessionId":"740045F3-6F21-4E04-8AC2-89D314CE762F"}
2025-02-08 20:15:16:040 [1c5a3a6c][Mac2Driver@e0f7] Responding to client with driver.execute() result: {"uuid":"EFEAE31F-C055-4699-89D0-A983644A6D4B","startedAt":1739016903.0187821,"fps":24,"codec":0,"displayId":1}
2025-02-08 20:15:16:041 [1c5a3a6c][HTTP] <-- POST /session/1c5a3a6c-c3a0-4cfb-ab36-e43b66e62d92/execute/sync 200 48 ms - 121
2025-02-08 20:15:16:043 [1c5a3a6c][HTTP] --> POST /session/1c5a3a6c-c3a0-4cfb-ab36-e43b66e62d92/execute/sync {"script":"macos: stopNativeScreenRecording","args":[]}
2025-02-08 20:15:16:044 [1c5a3a6c][Mac2Driver@e0f7] Calling AppiumDriver.execute() with args: ["macos: stopNativeScreenRecording",[],"1c5a3a6c-c3a0-4cfb-ab36-e43b66e62d92"]
2025-02-08 20:15:16:044 [1c5a3a6c][Mac2Driver@e0f7] Executing extension command 'macos: stopNativeScreenRecording'
2025-02-08 20:15:16:049 [1c5a3a6c][WD Proxy] Proxying [POST /wda/video/stop] to [POST http://127.0.0.1:10100/session/740045F3-6F21-4E04-8AC2-89D314CE762F/wda/video/stop] with body: {}
2025-02-08 20:15:16:159 [1c5a3a6c][WD Proxy] Got response with status 200: {"value":{"uuid":"EFEAE31F-C055-4699-89D0-A983644A6D4B","startedAt":1739016903.0187821,"fps":24,"codec":0,"displayId":1},"sessionId":"740045F3-6F21-4E04-8AC2-89D314CE762F"}
2025-02-08 20:15:16:238 [1c5a3a6c][Mac2Driver@e0f7] The size of the resulting screen recording is 9.31 MB
2025-02-08 20:15:16:353 [1c5a3a6c][Mac2Driver@e0f7] Successfully deleted 1 leftover video recording
2025-02-08 20:15:16:385 [1c5a3a6c][Mac2Driver@e0f7] Responding to client with driver.execute() result: "AAAAHGZ0eXBtcDQyAAAAAWlzb21tcDQxbXA0MgAAAAFtZGF0AAAAAACU9qQAAAAeBgUaR1ZK3FxMQz+U78URPNFDqAH/zMz/AgJk9UCAAAko7CW4IA//7IN6XCEH+C42N9s3q4/P+W3tgRRBDUAAAAMAAAMAAAMAAAMAAAMAAa9zRqfT9ZBu4HPnbCn2qFjWSTq1GhMeAOgrR97s0Y7IMpYisDC/q3B2jv7wPH7710IjdU6hIwkQ3+n0IwkB1VVlW3fL+Je3Is43ZNXmsOckEPoosHQL6/Nlpgf/0uhvHx3SejSLf10JM+51SzNKwzkZfM6tsITtWcGgYlDJwiH4+vHaqYeazsXekY7DpNZDps77/uEcMPOF/RH5KIcWULaV8mEiJ1An6yocaI/2mtyhjzbvqURsUNXT0putgdvWJoqhbE74o4mNWryb/x92zUNmMKTHYMlj6Txzv8KpDYQ/as9/XZdDKnXBi6hKPt/VDOjY2QsuRiEwY6hLRaFbnBpDcYwPPpuMlmRcP6QJP9IRKzF2Z4HhKOF2c097DtydzHuGN1ILx1qV13IGNm82fwQxE4Vv8zQKqJfpnkwy+th+/3WuDmP6UiXBDxIjgtgSzobibYKq0UFqQ3aKaeM4Oga2hjN0yClohTsTKs/ZH7KaF9kRekEKqW7GDljtEp9vPzPAgeGn/3DEX3Hj4Ba4/Xyl7B8ft7/jiTrXtZBQ5S/q2vXQFPkHJ4BpDCLXK8B9axs7OOykwtjXt9V+/CIiEZlx91YDeRAWLNAzS1vCPBpk9qT1wwa/nd4ui8L5IJV/rlEnJhlTnQc7AzYntrLUKzJwD3O2LF3cFNqvO8hyHTPOPtlZkDQXtI9eTRF4/cu5J9nH1tdytSVeny1JwkkCqDV9W0IfJnK8zFNPqaYKnYq/7L4GDF0DROVwGKasyrQ5tS5TsXHp3H1RZ96IlgqAoRBOf/DdeYbjB10yiKmgtrJgubNOw+Xl2XqEwd67ur4jIYOZbhl8/iHjE+RObK/f...
2025-02-08 20:15:16:450 [1c5a3a6c][HTTP] <-- POST /session/1c5a3a6c-c3a0-4cfb-ab36-e43b66e62d92/execute/sync 200 400 ms - 13020688
2025-02-08 20:15:17:644 [1c5a3a6c][HTTP] --> POST /session/1c5a3a6c-c3a0-4cfb-ab36-e43b66e62d92/execute/sync {"script":"macos: startNativeScreenRecording","args":[]}
2025-02-08 20:15:17:645 [1c5a3a6c][Mac2Driver@e0f7] Calling AppiumDriver.execute() with args: ["macos: startNativeScreenRecording",[],"1c5a3a6c-c3a0-4cfb-ab36-e43b66e62d92"]
2025-02-08 20:15:17:646 [1c5a3a6c][Mac2Driver@e0f7] Executing extension command 'macos: startNativeScreenRecording'
2025-02-08 20:15:17:672 [1c5a3a6c][WD Proxy] Proxying [POST /wda/video/start] to [POST http://127.0.0.1:10100/session/740045F3-6F21-4E04-8AC2-89D314CE762F/wda/video/start] with body: {}
2025-02-08 20:15:17:793 [1c5a3a6c][WD Proxy] Got response with status 500: {"value":{"error":"unknown error","message":"Error Domain=XCTDaemon.ScreenRecordingError Code=0 "Already recording, there can only be one screen recording at a time." UserInfo={NSLocalizedFailure=Failed to start screen recording., NSLocalizedRecoverySuggestion=Stop the currently active screen recording first and try again., NSLocalizedFailureReason=Already recording, there can only be one screen recording at a time.}","traceback":""},"sessionId":"740045F3-6F21-4E04-8AC2-89D314CE762F"}
2025-02-08 20:15:17:794 [1c5a3a6c][W3C] Matched W3C error code 'unknown error' to UnknownError
2025-02-08 20:15:17:804 [1c5a3a6c][Mac2Driver@e0f7] Encountered internal error running command: UnknownError: An unknown server-side error occurred while processing the command. Original error: Error Domain=XCTDaemon.ScreenRecordingError Code=0 "Already recording, there can only be one screen recording at a time." UserInfo={NSLocalizedFailure=Failed to start screen recording., NSLocalizedRecoverySuggestion=Stop the currently active screen recording first and try again., NSLocalizedFailureReason=Already recording, there can only be one screen recording at a time.}
at errorFromW3CJsonCode (/opt/homebrew/lib/node_modules/appium/node_modules/@appium/base-driver/lib/protocol/errors.js:1112:25)
at ProxyRequestError.getActualError (/opt/homebrew/lib/node_modules/appium/node_modules/@appium/base-driver/lib/protocol/errors.js:981:14)
at WDAMacProxy.command (/opt/homebrew/lib/node_modules/appium/node_modules/@appium/base-driver/lib/jsonwp-proxy/proxy.js:348:19)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at Mac2Driver.macosStartNativeScreenRecording (/Users/labtest/.appium/node_modules/appium-mac2-driver/lib/commands/native-record-screen.ts:29:18)
at Mac2Driver.executeMethod (/opt/homebrew/lib/node_modules/appium/node_modules/@appium/base-driver/lib/basedriver/commands/execute.ts:36:12)
at Mac2Driver.execute (/Users/labtest/.appium/node_modules/appium-mac2-driver/lib/commands/execute.js:16:10)
2025-02-08 20:15:17:806 [1c5a3a6c][HTTP] <-- POST /session/1c5a3a6c-c3a0-4cfb-ab36-e43b66e62d92/execute/sync 500 162 ms - 1908
2025-02-08 20:17:23:042 [Appium] Received SIGINT - shutting down
2025-02-08 20:17:23:047 [AppiumDriver@40dc] Cleaning up 1 active session
2025-02-08 20:17:23:048 [AppiumDriver@40dc] Ending session, cause was 'The process has received SIGINT signal'
2025-02-08 20:17:23:048 [AppiumDriver@40dc] Removing session '1c5a3a6c-c3a0-4cfb-ab36-e43b66e62d92' from our master session list
2025-02-08 20:17:23:051 [WD Proxy] Matched '/session/740045F3-6F21-4E04-8AC2-89D314CE762F' to command name 'deleteSession'
2025-02-08 20:17:23:052 [WD Proxy] Proxying [DELETE /session/740045F3-6F21-4E04-8AC2-89D314CE762F] to [DELETE http://127.0.0.1:10100/session/740045F3-6F21-4E04-8AC2-89D314CE762F] with no body
2025-02-08 20:17:23:059 [WD Proxy] Got response with status 200: {"value":null,"sessionId":null}

@mykola-mokhnach
Copy link
Contributor

mykola-mokhnach commented Feb 8, 2025

2025-02-08 20:15:02:445 [1c5a3a6c][WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:10100/status] with no body
2025-02-08 20:15:02:459 [1c5a3a6c][WD Proxy] Got response with status 200: {"value":{"message":"WebDriverAgent is ready to accept commands","state":"success","os":{"version":"版本14.4(版号23E214)"},"ready":true,"build":{"time":"Feb 8 2025 11:41:16"}},"sessionId":null}

I assume this might be an Apple issue, since the video recording feature has only been officially enabled since Xcode SDK 15. Please update your Xcode and try again

@tgz0514
Copy link
Author

tgz0514 commented Feb 8, 2025

2025-02-08 20:15:02:445 [1c5a3a6c][WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:10100/status] with no body
2025-02-08 20:15:02:459 [1c5a3a6c][WD Proxy] Got response with status 200: {"value":{"message":"WebDriverAgent is ready to accept commands","state":"success","os":{"version":"版本14.4(版号23E214)"},"ready":true,"build":{"time":"Feb 8 2025 11:41:16"}},"sessionId":null}

I assume this might be an Apple issue, since the video recording feature has only been officially enabled since Xcode SDK 15. Please update your Xcode and try again

My macOS version is 14.4, and Xcode version is 15.3

@mykola-mokhnach
Copy link
Contributor

mykola-mokhnach commented Feb 8, 2025

cd /Users/labtest/.appium/node_modules/appium-mac2-driver/WebDriverAgentMac/WebDriverAgentMac.xcodeproj
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang-stat-cache /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk -o /Users/labtest/Library/Developer/Xcode/DerivedData/SDKStatCaches.noindex/macosx14.4-23E208-13f6e737bddbb37f317b3579f3535bf5.sdkstatcache

Even though Xcode is fairly new it still uses an old SDK for compilation. Nevertheless I don't have any other good advices there, except of updating/upgrading Xcode/macOS

@tgz0514
Copy link
Author

tgz0514 commented Feb 10, 2025

cd /Users/labtest/.appium/node_modules/appium-mac2-driver/WebDriverAgentMac/WebDriverAgentMac.xcodeproj
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang-stat-cache /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk -o /Users/labtest/Library/Developer/Xcode/DerivedData/SDKStatCaches.noindex/macosx14.4-23E208-13f6e737bddbb37f317b3579f3535bf5.sdkstatcache

Even though Xcode is fairly new it still uses an old SDK for compilation. Nevertheless I don't have any other good advices there, except of updating/upgrading Xcode/macOS

Please tell me your Mac OS version and Xcode version

@mykola-mokhnach
Copy link
Contributor

macOS 15.2, Xcode 16.2

@tgz0514
Copy link
Author

tgz0514 commented Feb 10, 2025

After upgrading to the latest versions (macOS 15.3 and Xcode 16.2), the startNativeScreenRecording issue has been resolved. The second execution of the command no longer throws an error.

Environment details:

  • macOS: 15.3
  • Xcode: 16.2

While this works well on updated systems, I understand this may not be a viable solution for everyone. Many testing environments are running on older hardware or systems that cannot be upgraded due to various constraints (hardware limitations, compatibility requirements, or organizational policies).

For those who cannot upgrade, unfortunately, this remains a known limitation. You may need to:

  1. Consider alternative recording methods
  2. Reset the recording session between tests
  3. Implement workarounds specific to your environment's version

If anyone has found solutions for older versions, please feel free to share them here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants