Skip to content

Commit

Permalink
feat: Make native screen recording and screenshots configurable (#291)
Browse files Browse the repository at this point in the history
  • Loading branch information
mykola-mokhnach authored Mar 19, 2024
1 parent 755c3bd commit 9f594c4
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
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

0 comments on commit 9f594c4

Please sign in to comment.