diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2053ab6e5..63a285a38 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,10 @@
+## [8.7.0](https://github.com/appium/WebDriverAgent/compare/v8.6.0...v8.7.0) (2024-06-01)
+
+
+### Features
+
+* Add a setting to respect system alerts while detecting active apps ([#907](https://github.com/appium/WebDriverAgent/issues/907)) ([5c82d66](https://github.com/appium/WebDriverAgent/commit/5c82d66890b1a74f9b6f698c87590b2154a6c1bd))
+
## [8.6.0](https://github.com/appium/WebDriverAgent/compare/v8.5.7...v8.6.0) (2024-05-17)
diff --git a/WebDriverAgentLib/Commands/FBSessionCommands.m b/WebDriverAgentLib/Commands/FBSessionCommands.m
index c490a6820..7b3c4dbb5 100644
--- a/WebDriverAgentLib/Commands/FBSessionCommands.m
+++ b/WebDriverAgentLib/Commands/FBSessionCommands.m
@@ -345,6 +345,7 @@ + (NSArray *)routes
FB_SETTING_DISMISS_ALERT_BUTTON_SELECTOR: FBConfiguration.dismissAlertButtonSelector,
FB_SETTING_DEFAULT_ALERT_ACTION: request.session.defaultAlertAction ?: @"",
FB_SETTING_MAX_TYPING_FREQUENCY: @([FBConfiguration maxTypingFrequency]),
+ FB_SETTING_RESPECT_SYSTEM_ALERTS: @([FBConfiguration shouldRespectSystemAlerts]),
#if !TARGET_OS_TV
FB_SETTING_SCREENSHOT_ORIENTATION: [FBConfiguration humanReadableScreenshotOrientation],
#endif
@@ -385,6 +386,9 @@ + (NSArray *)routes
if (nil != [settings objectForKey:FB_SETTING_KEYBOARD_PREDICTION]) {
[FBConfiguration setKeyboardPrediction:[[settings objectForKey:FB_SETTING_KEYBOARD_PREDICTION] boolValue]];
}
+ if (nil != [settings objectForKey:FB_SETTING_RESPECT_SYSTEM_ALERTS]) {
+ [FBConfiguration setShouldRespectSystemAlerts:[[settings objectForKey:FB_SETTING_RESPECT_SYSTEM_ALERTS] boolValue]];
+ }
// SNAPSHOT_TIMEOUT setting is deprecated. Please use CUSTOM_SNAPSHOT_TIMEOUT instead
if (nil != [settings objectForKey:FB_SETTING_SNAPSHOT_TIMEOUT]) {
[FBConfiguration setCustomSnapshotTimeout:[[settings objectForKey:FB_SETTING_SNAPSHOT_TIMEOUT] doubleValue]];
diff --git a/WebDriverAgentLib/Info.plist b/WebDriverAgentLib/Info.plist
index 1d6637a44..f4acb11de 100644
--- a/WebDriverAgentLib/Info.plist
+++ b/WebDriverAgentLib/Info.plist
@@ -15,11 +15,11 @@
CFBundlePackageType
FMWK
CFBundleShortVersionString
- 8.6.0
+ 8.7.0
CFBundleSignature
????
CFBundleVersion
- 8.6.0
+ 8.7.0
NSPrincipalClass
diff --git a/WebDriverAgentLib/Routing/FBSession.m b/WebDriverAgentLib/Routing/FBSession.m
index 82134e0cc..2b1753cd2 100644
--- a/WebDriverAgentLib/Routing/FBSession.m
+++ b/WebDriverAgentLib/Routing/FBSession.m
@@ -176,6 +176,10 @@ - (XCUIApplication *)activeApplication
if (nil != self.testedApplication) {
XCUIApplicationState testedAppState = self.testedApplication.state;
if (testedAppState >= XCUIApplicationStateRunningForeground) {
+ if ([FBConfiguration shouldRespectSystemAlerts]
+ && [XCUIApplication.fb_systemApplication descendantsMatchingType:XCUIElementTypeAlert].count > 0) {
+ return XCUIApplication.fb_systemApplication;
+ }
return (XCUIApplication *)self.testedApplication;
}
if (self.isTestedApplicationExpectedToRun && testedAppState <= XCUIApplicationStateNotRunning) {
diff --git a/WebDriverAgentLib/Utilities/FBConfiguration.h b/WebDriverAgentLib/Utilities/FBConfiguration.h
index c07c31a1e..dc2018928 100644
--- a/WebDriverAgentLib/Utilities/FBConfiguration.h
+++ b/WebDriverAgentLib/Utilities/FBConfiguration.h
@@ -66,6 +66,10 @@ extern NSString *const FBSnapshotMaxDepthKey;
+ (void)setShouldUseSingletonTestManager:(BOOL)value;
+ (BOOL)shouldUseSingletonTestManager;
+/* Enforces WDA to verify the presense of system alerts while checking for an active app */
++ (void)setShouldRespectSystemAlerts:(BOOL)value;
++ (BOOL)shouldRespectSystemAlerts;
+
/**
* Extract switch value from arguments
*
diff --git a/WebDriverAgentLib/Utilities/FBConfiguration.m b/WebDriverAgentLib/Utilities/FBConfiguration.m
index 3bb740a0b..1d7438ae1 100644
--- a/WebDriverAgentLib/Utilities/FBConfiguration.m
+++ b/WebDriverAgentLib/Utilities/FBConfiguration.m
@@ -31,6 +31,7 @@
static BOOL FBShouldUseTestManagerForVisibilityDetection = NO;
static BOOL FBShouldUseSingletonTestManager = YES;
+static BOOL FBShouldRespectSystemAlerts = NO;
static NSUInteger FBMjpegScalingFactor = 100;
static BOOL FBMjpegShouldFixOrientation = NO;
@@ -373,6 +374,16 @@ + (int)snapshotMaxDepth
return [FBGetCustomParameterForElementSnapshot(FBSnapshotMaxDepthKey) intValue];
}
++ (void)setShouldRespectSystemAlerts:(BOOL)value
+{
+ FBShouldRespectSystemAlerts = value;
+}
+
++ (BOOL)shouldRespectSystemAlerts
+{
+ return FBShouldRespectSystemAlerts;
+}
+
+ (void)setUseFirstMatch:(BOOL)enabled
{
FBShouldUseFirstMatch = enabled;
diff --git a/WebDriverAgentLib/Utilities/FBSettings.h b/WebDriverAgentLib/Utilities/FBSettings.h
index 98862f0a0..5f4450110 100644
--- a/WebDriverAgentLib/Utilities/FBSettings.h
+++ b/WebDriverAgentLib/Utilities/FBSettings.h
@@ -39,6 +39,7 @@ extern NSString* const FB_SETTING_SCREENSHOT_ORIENTATION;
extern NSString* const FB_SETTING_WAIT_FOR_IDLE_TIMEOUT;
extern NSString* const FB_SETTING_ANIMATION_COOL_OFF_TIMEOUT;
extern NSString* const FB_SETTING_MAX_TYPING_FREQUENCY;
+extern NSString* const FB_SETTING_RESPECT_SYSTEM_ALERTS;
NS_ASSUME_NONNULL_END
diff --git a/WebDriverAgentLib/Utilities/FBSettings.m b/WebDriverAgentLib/Utilities/FBSettings.m
index d4715d9a0..a45afeb90 100644
--- a/WebDriverAgentLib/Utilities/FBSettings.m
+++ b/WebDriverAgentLib/Utilities/FBSettings.m
@@ -34,3 +34,4 @@
NSString* const FB_SETTING_WAIT_FOR_IDLE_TIMEOUT = @"waitForIdleTimeout";
NSString* const FB_SETTING_ANIMATION_COOL_OFF_TIMEOUT = @"animationCoolOffTimeout";
NSString* const FB_SETTING_MAX_TYPING_FREQUENCY = @"maxTypingFrequency";
+NSString* const FB_SETTING_RESPECT_SYSTEM_ALERTS = @"respectSystemAlerts";
diff --git a/package.json b/package.json
index 371d8b480..c53f7eb20 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "appium-webdriveragent",
- "version": "8.6.0",
+ "version": "8.7.0",
"description": "Package bundling WebDriverAgent",
"main": "./build/index.js",
"types": "./build/index.d.ts",