diff --git a/README.md b/README.md index e6bbbde..a76c880 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/WebDriverAgentMac/WebDriverAgentLib/Utilities/FBConfiguration.h b/WebDriverAgentMac/WebDriverAgentLib/Utilities/FBConfiguration.h index c170284..8ff2db4 100644 --- a/WebDriverAgentMac/WebDriverAgentLib/Utilities/FBConfiguration.h +++ b/WebDriverAgentMac/WebDriverAgentLib/Utilities/FBConfiguration.h @@ -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 */ diff --git a/WebDriverAgentMac/WebDriverAgentLib/Utilities/FBConfiguration.m b/WebDriverAgentMac/WebDriverAgentLib/Utilities/FBConfiguration.m index 703c388..5265061 100644 --- a/WebDriverAgentMac/WebDriverAgentLib/Utilities/FBConfiguration.m +++ b/WebDriverAgentMac/WebDriverAgentLib/Utilities/FBConfiguration.m @@ -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 diff --git a/WebDriverAgentMac/WebDriverAgentRunner/WebDriverAgentRunner.m b/WebDriverAgentMac/WebDriverAgentRunner/WebDriverAgentRunner.m index 943cd46..05d7406 100644 --- a/WebDriverAgentMac/WebDriverAgentRunner/WebDriverAgentRunner.m +++ b/WebDriverAgentMac/WebDriverAgentRunner/WebDriverAgentRunner.m @@ -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]; }