Skip to content

Commit f9518ed

Browse files
feat: expose customActions on the element
Add support for exposing custom accessibility actions from UI elements.
1 parent b6fc4e9 commit f9518ed

24 files changed

+344
-55
lines changed

WebDriverAgent.xcodeproj/project.pbxproj

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,7 @@
529529
71F5BE50252F14EB00EE9EBA /* FBExceptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 71F5BE4D252F14EB00EE9EBA /* FBExceptions.h */; };
530530
71F5BE51252F14EB00EE9EBA /* FBExceptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 71F5BE4E252F14EB00EE9EBA /* FBExceptions.m */; };
531531
71F5BE52252F14EB00EE9EBA /* FBExceptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 71F5BE4E252F14EB00EE9EBA /* FBExceptions.m */; };
532+
AABBCCDDEEFF001122334457 /* SceneDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = AABBCCDDEEFF001122334456 /* SceneDelegate.m */; };
532533
AD35D06C1CF1C35500870A75 /* WebDriverAgentLib.framework in Copy frameworks */ = {isa = PBXBuildFile; fileRef = EE158A991CBD452B00A3E3F0 /* WebDriverAgentLib.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
533534
AD6C26941CF2379700F8B5FF /* FBAlert.h in Headers */ = {isa = PBXBuildFile; fileRef = AD6C26921CF2379700F8B5FF /* FBAlert.h */; settings = {ATTRIBUTES = (Public, ); }; };
534535
AD6C26951CF2379700F8B5FF /* FBAlert.m in Sources */ = {isa = PBXBuildFile; fileRef = AD6C26931CF2379700F8B5FF /* FBAlert.m */; };
@@ -799,7 +800,6 @@
799800
EE9B76591CF7987800275851 /* FBRouteTests.m in Sources */ = {isa = PBXBuildFile; fileRef = EE9B76571CF7987300275851 /* FBRouteTests.m */; };
800801
EE9B768E1CF7997600275851 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = EE9B76831CF7997600275851 /* AppDelegate.m */; };
801802
EE9B768F1CF7997600275851 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = EE9B76851CF7997600275851 /* ViewController.m */; };
802-
AABBCCDDEEFF001122334457 /* SceneDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = AABBCCDDEEFF001122334456 /* SceneDelegate.m */; };
803803
EE9B76911CF7997600275851 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = EE9B76871CF7997600275851 /* main.m */; };
804804
EE9B76941CF7997600275851 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = EE9B768C1CF7997600275851 /* Main.storyboard */; };
805805
EE9B769A1CF799F400275851 /* FBAlertTests.m in Sources */ = {isa = PBXBuildFile; fileRef = EE9B76991CF799F400275851 /* FBAlertTests.m */; };
@@ -822,6 +822,10 @@
822822
EEE3764A1D59FAE900ED88DD /* XCUIElement+FBWebDriverAttributes.m in Sources */ = {isa = PBXBuildFile; fileRef = EEE376481D59FAE900ED88DD /* XCUIElement+FBWebDriverAttributes.m */; };
823823
EEE9B4721CD02B88009D2030 /* FBRunLoopSpinner.h in Headers */ = {isa = PBXBuildFile; fileRef = EEE9B4701CD02B88009D2030 /* FBRunLoopSpinner.h */; settings = {ATTRIBUTES = (Public, ); }; };
824824
EEE9B4731CD02B88009D2030 /* FBRunLoopSpinner.m in Sources */ = {isa = PBXBuildFile; fileRef = EEE9B4711CD02B88009D2030 /* FBRunLoopSpinner.m */; };
825+
F59CD6D42EF16E5E00F91287 /* XCUIElement+FBCustomActions.h in Headers */ = {isa = PBXBuildFile; fileRef = F59CD6D22EF16E5E00F91287 /* XCUIElement+FBCustomActions.h */; };
826+
F59CD6D52EF16E5E00F91287 /* XCUIElement+FBCustomActions.m in Sources */ = {isa = PBXBuildFile; fileRef = F59CD6D32EF16E5E00F91287 /* XCUIElement+FBCustomActions.m */; };
827+
F59CD6D62EF16E5E00F91287 /* XCUIElement+FBCustomActions.h in Headers */ = {isa = PBXBuildFile; fileRef = F59CD6D22EF16E5E00F91287 /* XCUIElement+FBCustomActions.h */; };
828+
F59CD6D72EF16E5E00F91287 /* XCUIElement+FBCustomActions.m in Sources */ = {isa = PBXBuildFile; fileRef = F59CD6D32EF16E5E00F91287 /* XCUIElement+FBCustomActions.m */; };
825829
/* End PBXBuildFile section */
826830

827831
/* Begin PBXContainerItemProxy section */
@@ -1110,6 +1114,8 @@
11101114
71F5BE33252E5B2200EE9EBA /* FBElementSwipingTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FBElementSwipingTests.m; sourceTree = "<group>"; };
11111115
71F5BE4D252F14EB00EE9EBA /* FBExceptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FBExceptions.h; sourceTree = "<group>"; };
11121116
71F5BE4E252F14EB00EE9EBA /* FBExceptions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FBExceptions.m; sourceTree = "<group>"; };
1117+
AABBCCDDEEFF001122334455 /* SceneDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SceneDelegate.h; sourceTree = "<group>"; };
1118+
AABBCCDDEEFF001122334456 /* SceneDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SceneDelegate.m; sourceTree = "<group>"; };
11131119
AD42DD2A1CF121E600806E5D /* module.modulemap */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.module-map"; path = module.modulemap; sourceTree = "<group>"; };
11141120
AD6C26921CF2379700F8B5FF /* FBAlert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FBAlert.h; path = WebDriverAgentLib/FBAlert.h; sourceTree = SOURCE_ROOT; };
11151121
AD6C26931CF2379700F8B5FF /* FBAlert.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; name = FBAlert.m; path = WebDriverAgentLib/FBAlert.m; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
@@ -1369,8 +1375,6 @@
13691375
EE9B76581CF7987300275851 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
13701376
EE9B76821CF7997600275851 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
13711377
EE9B76831CF7997600275851 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
1372-
AABBCCDDEEFF001122334455 /* SceneDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SceneDelegate.h; sourceTree = "<group>"; };
1373-
AABBCCDDEEFF001122334456 /* SceneDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SceneDelegate.m; sourceTree = "<group>"; };
13741378
EE9B76841CF7997600275851 /* ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = "<group>"; };
13751379
EE9B76851CF7997600275851 /* ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = "<group>"; };
13761380
EE9B76861CF7997600275851 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
@@ -1404,6 +1408,8 @@
14041408
EEE9B4701CD02B88009D2030 /* FBRunLoopSpinner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FBRunLoopSpinner.h; sourceTree = "<group>"; };
14051409
EEE9B4711CD02B88009D2030 /* FBRunLoopSpinner.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FBRunLoopSpinner.m; sourceTree = "<group>"; };
14061410
EEF9882A1C486603005CA669 /* WebDriverAgentRunner.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = WebDriverAgentRunner.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
1411+
F59CD6D22EF16E5E00F91287 /* XCUIElement+FBCustomActions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "XCUIElement+FBCustomActions.h"; sourceTree = "<group>"; };
1412+
F59CD6D32EF16E5E00F91287 /* XCUIElement+FBCustomActions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "XCUIElement+FBCustomActions.m"; sourceTree = "<group>"; };
14071413
/* End PBXFileReference section */
14081414

14091415
/* Begin PBXFrameworksBuildPhase section */
@@ -1820,6 +1826,8 @@
18201826
71E75E6C254824230099FC87 /* XCUIElementQuery+FBHelpers.m */,
18211827
13DE7A59287CA444003243C6 /* FBXCElementSnapshotWrapper+Helpers.h */,
18221828
13DE7A5A287CA444003243C6 /* FBXCElementSnapshotWrapper+Helpers.m */,
1829+
F59CD6D22EF16E5E00F91287 /* XCUIElement+FBCustomActions.h */,
1830+
F59CD6D32EF16E5E00F91287 /* XCUIElement+FBCustomActions.m */,
18231831
);
18241832
name = Categories;
18251833
path = WebDriverAgentLib/Categories;
@@ -2521,6 +2529,7 @@
25212529
641EE6E42240C5CA00173FCB /* XCKeyboardLayout.h in Headers */,
25222530
641EE6E52240C5CA00173FCB /* XCTAsyncActivity-Protocol.h in Headers */,
25232531
641EE6E62240C5CA00173FCB /* XCActivityRecord.h in Headers */,
2532+
F59CD6D62EF16E5E00F91287 /* XCUIElement+FBCustomActions.h in Headers */,
25242533
71822765258744C700661B83 /* HTTPDataResponse.h in Headers */,
25252534
641EE6E72240C5CA00173FCB /* XCUIElement+FBFind.h in Headers */,
25262535
641EE6E82240C5CA00173FCB /* XCTestManager_ManagerInterface-Protocol.h in Headers */,
@@ -2556,6 +2565,7 @@
25562565
719CD8F82126C78F00C7D0C2 /* FBAlertsMonitor.h in Headers */,
25572566
EE158AE41CBD456F00A3E3F0 /* FBSession.h in Headers */,
25582567
13DE7A55287CA1EC003243C6 /* FBXCElementSnapshotWrapper.h in Headers */,
2568+
F59CD6D42EF16E5E00F91287 /* XCUIElement+FBCustomActions.h in Headers */,
25592569
EE35AD0F1E3B77D600A02D78 /* _XCTestImplementation.h in Headers */,
25602570
71241D7B1FAE3D2500B9559F /* FBTouchActionCommands.h in Headers */,
25612571
EE158ACA1CBD456F00A3E3F0 /* FBTouchIDCommands.h in Headers */,
@@ -3117,6 +3127,7 @@
31173127
isa = PBXSourcesBuildPhase;
31183128
buildActionMask = 2147483647;
31193129
files = (
3130+
F59CD6D72EF16E5E00F91287 /* XCUIElement+FBCustomActions.m in Sources */,
31203131
64E3502E2AC0B6EB005F3ACB /* NSDictionary+FBUtf8SafeDictionary.m in Sources */,
31213132
718226CF2587443700661B83 /* GCDAsyncSocket.m in Sources */,
31223133
E444DCBC24917A5E0060D7EB /* HTTPResponseProxy.m in Sources */,
@@ -3323,6 +3334,7 @@
33233334
71D475C42538F5A8008D9401 /* XCUIApplicationProcess+FBQuiescence.m in Sources */,
33243335
641EE7082240CDEB00173FCB /* XCUIElement+FBTVFocuse.m in Sources */,
33253336
71E75E6F254824230099FC87 /* XCUIElementQuery+FBHelpers.m in Sources */,
3337+
F59CD6D52EF16E5E00F91287 /* XCUIElement+FBCustomActions.m in Sources */,
33263338
71D04DCA25356C43008A052C /* XCUIElement+FBCaching.m in Sources */,
33273339
EE158AEB1CBD456F00A3E3F0 /* FBRuntimeUtils.m in Sources */,
33283340
EEE376461D59F81400ED88DD /* XCUIElement+FBUtilities.m in Sources */,

WebDriverAgentLib/Categories/XCUIApplication+FBHelpers.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ + (NSDictionary *)dictionaryForElement:(id<FBXCElementSnapshot>)snapshot
204204
info[@"value"] = FBValueOrNull(wrappedSnapshot.wdValue);
205205
info[@"label"] = FBValueOrNull(wrappedSnapshot.wdLabel);
206206
info[@"rect"] = wrappedSnapshot.wdRect;
207+
info[@"customActions"] = FBValueOrNull(wrappedSnapshot.wdCustomActions);
207208

208209
NSDictionary<NSString *, NSString *(^)(void)> *attributeBlocks = [self fb_attributeBlockMapForWrappedSnapshot:wrappedSnapshot];
209210

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
#import <WebDriverAgentLib/FBXCElementSnapshotWrapper.h>
10+
11+
NS_ASSUME_NONNULL_BEGIN
12+
13+
@interface XCUIElement (FBCustomActions)
14+
15+
/*! Custom accessibility actions as a string – may be nil if the element does not have this attribute */
16+
@property (nonatomic, readonly, nullable) NSString *fb_customActions;
17+
18+
@end
19+
20+
@interface FBXCElementSnapshotWrapper (FBCustomActions)
21+
22+
/*! Custom accessibility actions as a string – may be nil if the element does not have this attribute */
23+
@property (nonatomic, readonly, nullable) NSString *fb_customActions;
24+
25+
@end
26+
27+
NS_ASSUME_NONNULL_END
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
#import "XCUIElement+FBCustomActions.h"
10+
#import "XCUIElement+FBUtilities.h"
11+
#import "FBXCElementSnapshotWrapper+Helpers.h"
12+
#import "FBLogger.h"
13+
#import "FBConfiguration.h"
14+
#import "XCTestPrivateSymbols.h"
15+
16+
@interface FBXCElementSnapshotWrapper (FBCustomActionsInternal)
17+
18+
- (NSString *)fb_stringAttribute:(NSString *)attributeName
19+
symbol:(NSNumber *)symbol;
20+
21+
@end
22+
23+
@implementation XCUIElement (FBCustomActions)
24+
25+
- (NSString *)fb_customActions
26+
{
27+
@autoreleasepool {
28+
id<FBXCElementSnapshot> snapshot = [self fb_standardSnapshot];
29+
return [[FBXCElementSnapshotWrapper ensureWrapped:snapshot]
30+
fb_customActions];
31+
}
32+
}
33+
34+
@end
35+
36+
37+
@implementation FBXCElementSnapshotWrapper(FBCustomActions)
38+
39+
- (NSString *)fb_customActions
40+
{
41+
return [self fb_stringAttribute:FB_XCAXACustomActionsAttributeName
42+
symbol:FB_XCAXACustomActionsAttribute];
43+
}
44+
45+
- (NSString *)fb_stringAttribute:(NSString *)attributeName
46+
symbol:(NSNumber *)symbol
47+
{
48+
id cached = (self.snapshot.additionalAttributes ?: @{})[symbol];
49+
if ([cached isKindOfClass:[NSString class]]) {
50+
return cached;
51+
}
52+
53+
NSError *error = nil;
54+
id raw = [self fb_attributeValue:attributeName error:&error];
55+
if (raw == nil) {
56+
[FBLogger logFmt: @"[FBCustomActions] Cannot determine string value for %@: %@",
57+
attributeName, error.localizedDescription];
58+
return nil;
59+
}
60+
61+
// Case 1: Already a string
62+
if ([raw isKindOfClass:[NSString class]]) {
63+
NSMutableDictionary *updated =
64+
(self.additionalAttributes ?: @{}).mutableCopy;
65+
updated[symbol] = raw;
66+
self.snapshot.additionalAttributes = updated.copy;
67+
return raw;
68+
}
69+
70+
// Case 2: Array of custom actions
71+
if ([raw isKindOfClass:[NSArray class]]) {
72+
NSMutableArray *stringified = [NSMutableArray array];
73+
for (id action in (NSArray *)raw) {
74+
NSString *title = nil;
75+
76+
if ([action isKindOfClass:[NSDictionary class]]) {
77+
title = ((NSDictionary *)action)[@"CustomActionName"];
78+
}
79+
80+
if (!title || ![title isKindOfClass:[NSString class]]) {
81+
@try {
82+
title = [action valueForKey:@"title"];
83+
} @catch (__unused NSException * e) {
84+
title = @"<unknown>";
85+
}
86+
}
87+
88+
[stringified addObject:title ?: @"<null>"];
89+
NSLog(@"[FBCustomActions] Custom action title: %@", title);
90+
}
91+
92+
NSString *joined = [stringified componentsJoinedByString:[FBConfiguration customActionsDelimiter]];
93+
NSMutableDictionary *updated =
94+
(self.additionalAttributes ?: @{}).mutableCopy;
95+
updated[symbol] = joined;
96+
self.snapshot.additionalAttributes = updated.copy;
97+
return joined;
98+
}
99+
100+
// Fallback: Try to cast to string
101+
NSString *stringValue = [NSString stringWithFormat:@"%@", raw];
102+
NSMutableDictionary *updated = (self.additionalAttributes ?: @{}).mutableCopy;
103+
updated[symbol] = stringValue;
104+
self.snapshot.additionalAttributes = updated.copy;
105+
return stringValue;
106+
}
107+
108+
@end

WebDriverAgentLib/Categories/XCUIElement+FBWebDriverAttributes.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#import "XCUIHitPointResult.h"
2525
#import "FBAccessibilityTraits.h"
2626
#import "XCUIElement+FBMinMax.h"
27+
#import "XCUIElement+FBCustomActions.h"
2728

2829
#define BROKEN_RECT CGRectMake(-1, -1, 0, 0)
2930

@@ -285,4 +286,9 @@ - (NSDictionary *)wdRect
285286
};
286287
}
287288

289+
- (NSString *)wdCustomActions
290+
{
291+
return self.fb_customActions;
292+
}
293+
288294
@end

WebDriverAgentLib/Commands/FBSessionCommands.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,8 @@ + (NSArray *)routes
355355
FB_SETTING_INCLUDE_HITTABLE_IN_PAGE_SOURCE: @([FBConfiguration includeHittableInPageSource]),
356356
FB_SETTING_INCLUDE_NATIVE_FRAME_IN_PAGE_SOURCE: @([FBConfiguration includeNativeFrameInPageSource]),
357357
FB_SETTING_INCLUDE_MIN_MAX_VALUE_IN_PAGE_SOURCE: @([FBConfiguration includeMinMaxValueInPageSource]),
358+
FB_SETTING_INCLUDE_CUSTOM_ACTIONS_IN_PAGE_SOURCE: @([FBConfiguration includeCustomActionsInPageSource]),
359+
FB_SETTING_CUSTOM_ACTIONS_DELIMITER: [FBConfiguration customActionsDelimiter],
358360
FB_SETTING_ENFORCE_CUSTOM_SNAPSHOTS: @([FBConfiguration enforceCustomSnapshots]),
359361
FB_SETTING_LIMIT_XPATH_CONTEXT_SCOPE: @([FBConfiguration limitXpathContextScope]),
360362
#if !TARGET_OS_TV
@@ -467,6 +469,12 @@ + (NSArray *)routes
467469
if (nil != [settings objectForKey:FB_SETTING_INCLUDE_MIN_MAX_VALUE_IN_PAGE_SOURCE]) {
468470
[FBConfiguration setIncludeMinMaxValueInPageSource:[[settings objectForKey:FB_SETTING_INCLUDE_MIN_MAX_VALUE_IN_PAGE_SOURCE] boolValue]];
469471
}
472+
if (nil != [settings objectForKey:FB_SETTING_INCLUDE_CUSTOM_ACTIONS_IN_PAGE_SOURCE]) {
473+
[FBConfiguration setIncludeCustomActionsInPageSource:[[settings objectForKey:FB_SETTING_INCLUDE_CUSTOM_ACTIONS_IN_PAGE_SOURCE] boolValue]];
474+
}
475+
if (nil != [settings objectForKey:FB_SETTING_CUSTOM_ACTIONS_DELIMITER]) {
476+
[FBConfiguration setCustomActionsDelimiter:(NSString *)[settings objectForKey:FB_SETTING_CUSTOM_ACTIONS_DELIMITER]];
477+
}
470478
if (nil != [settings objectForKey:FB_SETTING_ENFORCE_CUSTOM_SNAPSHOTS]) {
471479
[FBConfiguration setEnforceCustomSnapshots:[[settings objectForKey:FB_SETTING_ENFORCE_CUSTOM_SNAPSHOTS] boolValue]];
472480
}

WebDriverAgentLib/Routing/FBElement.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ NS_ASSUME_NONNULL_BEGIN
7676
/*! Element's maximum value */
7777
@property (nonatomic, readonly, strong, nullable) NSNumber *wdMaxValue;
7878

79+
/*! Element's custom actions */
80+
@property (nonatomic, readonly, strong, nullable) NSString *wdCustomActions;
81+
7982
/**
8083
Returns value of given property specified in WebDriver Spec
8184
Check the FBElement protocol to get list of supported attributes.

WebDriverAgentLib/Utilities/FBConfiguration.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,26 @@ typedef NS_ENUM(NSInteger, FBConfigurationKeyboardPreference) {
376376
+ (void)setIncludeMinMaxValueInPageSource:(BOOL)enabled;
377377
+ (BOOL)includeMinMaxValueInPageSource;
378378

379+
/**
380+
* Whether to include `customActions` attribute in the XML page source.
381+
* Custom actions represent accessibility actions available on UI elements.
382+
* This may affect performance if used on many elements.
383+
* Disabled by default.
384+
*
385+
* @param enabled Either YES or NO
386+
*/
387+
+ (void)setIncludeCustomActionsInPageSource:(BOOL)enabled;
388+
+ (BOOL)includeCustomActionsInPageSource;
389+
390+
/**
391+
* Sets the delimiter string used when joining custom action names.
392+
* Defaults to ", " (comma followed by space).
393+
*
394+
* @param delimiter The delimiter string to use when joining custom actions
395+
*/
396+
+ (void)setCustomActionsDelimiter:(NSString *)delimiter;
397+
+ (NSString *)customActionsDelimiter;
398+
379399
/**
380400
* Whether to enforce the use of custom snapshots instead of standard snapshots.
381401
* When enabled, fb_customSnapshot is always invoked instead of fb_standardSnapshot

WebDriverAgentLib/Utilities/FBConfiguration.m

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@
6363
static BOOL FBShouldIncludeHittableInPageSource = NO;
6464
static BOOL FBShouldIncludeNativeFrameInPageSource = NO;
6565
static BOOL FBShouldIncludeMinMaxValueInPageSource = NO;
66+
static BOOL FBShouldIncludeCustomActionsInPageSource = NO;
6667
static BOOL FBShouldEnforceCustomSnapshots = NO;
68+
static NSString *FBCustomActionsDelimiter;
6769

6870
@implementation FBConfiguration
6971

@@ -542,6 +544,7 @@ + (void)resetSessionSettings
542544
FBSetCustomParameterForElementSnapshot(FBSnapshotMaxDepthKey, @50);
543545
FBUseClearTextShortcut = YES;
544546
FBLimitXpathContextScope = YES;
547+
FBCustomActionsDelimiter = @", ";
545548
#if !TARGET_OS_TV
546549
FBScreenshotOrientation = UIInterfaceOrientationUnknown;
547550
#endif
@@ -687,6 +690,26 @@ + (BOOL)includeMinMaxValueInPageSource
687690
return FBShouldIncludeMinMaxValueInPageSource;
688691
}
689692

693+
+ (void)setIncludeCustomActionsInPageSource:(BOOL)enabled
694+
{
695+
FBShouldIncludeCustomActionsInPageSource = enabled;
696+
}
697+
698+
+ (BOOL)includeCustomActionsInPageSource
699+
{
700+
return FBShouldIncludeCustomActionsInPageSource;
701+
}
702+
703+
+ (void)setCustomActionsDelimiter:(NSString *)delimiter
704+
{
705+
FBCustomActionsDelimiter = delimiter ?: @", ";
706+
}
707+
708+
+ (NSString *)customActionsDelimiter
709+
{
710+
return FBCustomActionsDelimiter ?: @", ";
711+
}
712+
690713
+ (void)setEnforceCustomSnapshots:(BOOL)enabled
691714
{
692715
FBShouldEnforceCustomSnapshots = enabled;

WebDriverAgentLib/Utilities/FBSettings.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ extern NSString* const FB_SETTING_AUTO_CLICK_ALERT_SELECTOR;
4242
extern NSString *const FB_SETTING_INCLUDE_HITTABLE_IN_PAGE_SOURCE;
4343
extern NSString *const FB_SETTING_INCLUDE_NATIVE_FRAME_IN_PAGE_SOURCE;
4444
extern NSString *const FB_SETTING_INCLUDE_MIN_MAX_VALUE_IN_PAGE_SOURCE;
45+
extern NSString *const FB_SETTING_INCLUDE_CUSTOM_ACTIONS_IN_PAGE_SOURCE;
46+
extern NSString *const FB_SETTING_CUSTOM_ACTIONS_DELIMITER;
4547
extern NSString *const FB_SETTING_ENFORCE_CUSTOM_SNAPSHOTS;
4648

4749
NS_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)