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

feat: Make native screen recording and screenshots configurable #291

Merged
merged 2 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,22 @@ def test_sending_custom_keys(driver):

Parallel execution of multiple Mac2 driver instances is highly discouraged. Only one UI test must be running at the same time, since the access to accessibility layer is single-threaded. Also HID devices, like the mouse or the keyboard, must be acquired exclusively.

## Environment Variables

The server part of the driver recognizes the following environment variables:

- `ENABLE_AUTOMATIC_SCREENSHOTS`: enables automatic XCTest screenshots.
These screenshots are stored in the same folder where WDA test logs are located and are taken automatically.
This feature is disabled by default. Only enable it if you know what you are doing otherwise these
screenshots may quickly fill up the free disk space.
- `ENABLE_AUTOMATIC_SCREEN_RECORDINGS`: enables automatic XCTest screen recordings.
These screen recordings are stored in the same folder where WDA test logs are located and are taken automatically. This feature is disabled by default.
Only enable it if you know what you are doing otherwise these videos may quickly fill up the free disk space.
The native screen recording feature only works on Xcode 15+.
- `USE_PORT`. If enabled then the server listens on the given port. Otherwise, a random free port from the
10100..10200 range is selected. By default, the port is selected by the driver (see the `appium:systemPort`
capability description).
- `VERBOSE_LOGGING`. If enabled then server logs should include various verbose details. Disabled by default.

## Development & Testing

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ NS_ASSUME_NONNULL_BEGIN
/*! Enables XCTest automated screenshots taking */
@property BOOL automaticScreenshots;

/*! Enables XCTest automated screen recordings taking in Xcode 15+ */
@property BOOL automaticScreenRecordings;

/**
The range of ports that the HTTP Server should attempt to bind on launch
*/
Expand Down
12 changes: 12 additions & 0 deletions WebDriverAgentMac/WebDriverAgentLib/Utilities/FBConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ - (void)setAutomaticScreenshots:(BOOL)automaticScreenshots
forKey:@"DisableScreenshots"];
}

- (BOOL)automaticScreenRecordings
{
id value = [NSUserDefaults.standardUserDefaults objectForKey:@"DisableDiagnosticScreenRecordings"];
return nil == value ? YES : ![value boolValue];
}

- (void)setAutomaticScreenRecordings:(BOOL)automaticScreenRecordings
{
[[NSUserDefaults standardUserDefaults] setBool:!automaticScreenRecordings
forKey:@"DisableDiagnosticScreenRecordings"];
}

- (NSRange)bindingPortRange
{
// 'WebDriverAgent --port 8080' can be passed via the arguments to the process
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ @implementation UITestingUITests
+ (void)setUp
{
FBConfiguration.sharedConfiguration.attributeKeyPathAnalysis = NO;
FBConfiguration.sharedConfiguration.automaticScreenshots = NO;
FBConfiguration.sharedConfiguration.automaticScreenshots =
[NSProcessInfo.processInfo.environment[@"ENABLE_AUTOMATIC_SCREENSHOTS"] boolValue];
FBConfiguration.sharedConfiguration.automaticScreenRecordings =
[NSProcessInfo.processInfo.environment[@"ENABLE_AUTOMATIC_SCREEN_RECORDINGS"] boolValue];
[super setUp];
}

Expand Down
Loading