appium-webdriveragent 4.10.2 → 4.10.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1 +1,3 @@
1
+ ## [4.10.3](https://github.com/appium/WebDriverAgent/compare/v4.10.2...v4.10.3) (2022-11-22)
2
+
1
3
  ## [4.10.2](https://github.com/appium/WebDriverAgent/compare/v4.10.1...v4.10.2) (2022-11-06)
@@ -9,8 +9,6 @@
9
9
 
10
10
  #import "XCUIElement+FBWebDriverAttributes.h"
11
11
 
12
- #import <objc/runtime.h>
13
-
14
12
  #import "FBElementTypeTransformer.h"
15
13
  #import "FBLogger.h"
16
14
  #import "FBMacros.h"
@@ -58,11 +56,15 @@
58
56
 
59
57
  - (id)forwardingTargetForSelector:(SEL)aSelector
60
58
  {
61
- struct objc_method_description descr = protocol_getMethodDescription(@protocol(FBElement), aSelector, YES, YES);
62
- SEL webDriverAttributesSelector = descr.name;
63
- return nil == webDriverAttributesSelector
64
- ? nil
65
- : [FBXCElementSnapshotWrapper ensureWrapped:[self fb_snapshotForAttributeName:NSStringFromSelector(webDriverAttributesSelector)]];
59
+ static dispatch_once_t onceToken;
60
+ static NSSet<NSString *> *fbElementAttributeNames;
61
+ dispatch_once(&onceToken, ^{
62
+ fbElementAttributeNames = [FBElementUtils selectorNamesWithProtocol:@protocol(FBElement)];
63
+ });
64
+ NSString* attributeName = NSStringFromSelector(aSelector);
65
+ return [fbElementAttributeNames containsObject:attributeName]
66
+ ? [FBXCElementSnapshotWrapper ensureWrapped:[self fb_snapshotForAttributeName:attributeName]]
67
+ : nil;
66
68
  }
67
69
 
68
70
  @end
@@ -88,6 +88,8 @@
88
88
  if (nil == (capabilities = FBParseCapabilities((NSDictionary *)request.arguments[@"capabilities"], &error))) {
89
89
  return FBResponseWithStatus([FBCommandStatus sessionNotCreatedError:error.description traceback:nil]);
90
90
  }
91
+
92
+ [FBConfiguration resetSessionSettings];
91
93
  [FBConfiguration setShouldUseTestManagerForVisibilityDetection:[capabilities[FB_CAP_USE_TEST_MANAGER_FOR_VISIBLITY_DETECTION] boolValue]];
92
94
  if (capabilities[FB_SETTING_USE_COMPACT_RESPONSES]) {
93
95
  [FBConfiguration setShouldUseCompactResponses:[capabilities[FB_SETTING_USE_COMPACT_RESPONSES] boolValue]];
@@ -96,8 +98,8 @@
96
98
  if (elementResponseAttributes) {
97
99
  [FBConfiguration setElementResponseAttributes:elementResponseAttributes];
98
100
  }
99
- if (capabilities[FB_CAP_MAX_TYPING_FREQUNCY]) {
100
- [FBConfiguration setMaxTypingFrequency:[capabilities[FB_CAP_MAX_TYPING_FREQUNCY] unsignedIntegerValue]];
101
+ if (capabilities[FB_CAP_MAX_TYPING_FREQUENCY]) {
102
+ [FBConfiguration setMaxTypingFrequency:[capabilities[FB_CAP_MAX_TYPING_FREQUENCY] unsignedIntegerValue]];
101
103
  }
102
104
  if (capabilities[FB_CAP_USE_SINGLETON_TEST_MANAGER]) {
103
105
  [FBConfiguration setShouldUseSingletonTestManager:[capabilities[FB_CAP_USE_SINGLETON_TEST_MANAGER] boolValue]];
@@ -380,10 +382,9 @@
380
382
  NSError *error;
381
383
  if (![FBConfiguration setScreenshotOrientation:(NSString *)[settings objectForKey:FB_SETTING_SCREENSHOT_ORIENTATION]
382
384
  error:&error]) {
383
- return FBResponseWithStatus([FBCommandStatus invalidArgumentErrorWithMessage:error.description traceback:nil]);
385
+ return FBResponseWithStatus([FBCommandStatus invalidArgumentErrorWithMessage:error.description
386
+ traceback:nil]);
384
387
  }
385
-
386
-
387
388
  }
388
389
  #endif
389
390
 
@@ -64,6 +64,14 @@ extern NSString *const FBUnknownAttributeException;
64
64
  */
65
65
  + (unsigned long long)idWithAccessibilityElement:(id<FBXCAccessibilityElement>)element;
66
66
 
67
+ /**
68
+ Retrieves the list of required insatnce methods of the given protocol
69
+
70
+ @param protocol target protocol reference
71
+ @return set of selector names
72
+ */
73
+ + (NSSet<NSString *> *)selectorNamesWithProtocol:(Protocol *)protocol;
74
+
67
75
  @end
68
76
 
69
77
  NS_ASSUME_NONNULL_END
@@ -20,11 +20,26 @@ static NSString *const OBJC_PROP_ATTRIBS_SEPARATOR = @",";
20
20
 
21
21
  @implementation FBElementUtils
22
22
 
23
+ + (NSSet<NSString *> *)selectorNamesWithProtocol:(Protocol *)protocol
24
+ {
25
+ unsigned int count;
26
+ struct objc_method_description *methods = protocol_copyMethodDescriptionList(protocol, YES, YES, &count);
27
+ NSMutableSet<NSString *> *result = [NSMutableSet set];
28
+ for (unsigned int i = 0; i < count; i++) {
29
+ SEL sel = methods[i].name;
30
+ if (nil != sel) {
31
+ [result addObject:NSStringFromSelector(sel)];
32
+ }
33
+ }
34
+ free(methods);
35
+ return result.copy;
36
+ }
37
+
23
38
  + (NSString *)wdAttributeNameForAttributeName:(NSString *)name
24
39
  {
25
40
  NSAssert(name.length > 0, @"Attribute name cannot be empty", nil);
26
41
  NSDictionary *attributeNamesMapping = [self.class wdAttributeNamesMapping];
27
- NSString *result = [attributeNamesMapping valueForKey:name];
42
+ NSString *result = attributeNamesMapping[name];
28
43
  if (nil == result) {
29
44
  NSString *description = [NSString stringWithFormat:@"The attribute '%@' is unknown. Valid attribute names are: %@", name, [attributeNamesMapping.allKeys sortedArrayUsingSelector:@selector(compare:)]];
30
45
  @throw [NSException exceptionWithName:FBUnknownAttributeException reason:description userInfo:@{}];
@@ -9,7 +9,7 @@
9
9
 
10
10
  #import "FBXCElementSnapshotWrapper.h"
11
11
 
12
- #import <objc/runtime.h>
12
+ #import "FBElementUtils.h"
13
13
 
14
14
  #pragma clang diagnostic push
15
15
  #pragma clang diagnostic ignored "-Wobjc-protocol-property-synthesis"
@@ -35,9 +35,15 @@
35
35
 
36
36
  - (id)forwardingTargetForSelector:(SEL)aSelector
37
37
  {
38
- struct objc_method_description descr = protocol_getMethodDescription(@protocol(FBXCElementSnapshot), aSelector, YES, YES);
39
- SEL selector = descr.name;
40
- return nil == selector ? nil : self.snapshot;
38
+ static dispatch_once_t onceToken;
39
+ static NSSet<NSString *> *allNames;
40
+ dispatch_once(&onceToken, ^{
41
+ NSMutableSet<NSString *> *names = [NSMutableSet set];
42
+ [names unionSet:[FBElementUtils selectorNamesWithProtocol:@protocol(FBXCElementSnapshot)]];
43
+ [names unionSet:[FBElementUtils selectorNamesWithProtocol:@protocol(XCUIElementAttributes)]];
44
+ allNames = [names copy];
45
+ });
46
+ return [allNames containsObject:NSStringFromSelector(aSelector)] ? self.snapshot : nil;
41
47
  }
42
48
 
43
49
  @end
@@ -10,7 +10,7 @@
10
10
  #import <Foundation/Foundation.h>
11
11
 
12
12
  extern NSString* const FB_CAP_USE_TEST_MANAGER_FOR_VISIBLITY_DETECTION;
13
- extern NSString* const FB_CAP_MAX_TYPING_FREQUNCY;
13
+ extern NSString* const FB_CAP_MAX_TYPING_FREQUENCY;
14
14
  extern NSString* const FB_CAP_USE_SINGLETON_TEST_MANAGER;
15
15
  extern NSString* const FB_CAP_DISABLE_AUTOMATIC_SCREENSHOTS;
16
16
  extern NSString* const FB_CAP_SHOULD_TERMINATE_APP;
@@ -10,7 +10,7 @@
10
10
  #import "FBCapabilities.h"
11
11
 
12
12
  NSString* const FB_CAP_USE_TEST_MANAGER_FOR_VISIBLITY_DETECTION = @"shouldUseTestManagerForVisibilityDetection";
13
- NSString* const FB_CAP_MAX_TYPING_FREQUNCY = @"maxTypingFrequency";
13
+ NSString* const FB_CAP_MAX_TYPING_FREQUENCY = @"maxTypingFrequency";
14
14
  NSString* const FB_CAP_USE_SINGLETON_TEST_MANAGER = @"shouldUseSingletonTestManager";
15
15
  NSString* const FB_CAP_DISABLE_AUTOMATIC_SCREENSHOTS = @"disableAutomaticScreenshots";
16
16
  NSString* const FB_CAP_SHOULD_TERMINATE_APP = @"shouldTerminateApp";
@@ -301,6 +301,11 @@ typedef NS_ENUM(NSInteger, FBConfigurationKeyboardPreference) {
301
301
 
302
302
  #endif
303
303
 
304
+ /**
305
+ Resets all session-specific settings to their default values
306
+ */
307
+ + (void)resetSessionSettings;
308
+
304
309
  @end
305
310
 
306
311
  NS_ASSUME_NONNULL_END
@@ -30,30 +30,30 @@ static NSString *const axSettingsClassName = @"AXSettings";
30
30
 
31
31
  static BOOL FBShouldUseTestManagerForVisibilityDetection = NO;
32
32
  static BOOL FBShouldUseSingletonTestManager = YES;
33
- static BOOL FBShouldUseCompactResponses = YES;
34
- static BOOL FBShouldTerminateApp = YES;
35
- static NSString *FBElementResponseAttributes = @"type,label";
36
- static NSUInteger FBMaxTypingFrequency = 60;
33
+ NSString *const FBSnapshotMaxDepthKey = @"maxDepth";
34
+
35
+ static NSUInteger FBMjpegScalingFactor = 100;
37
36
  static NSUInteger FBMjpegServerScreenshotQuality = 25;
38
37
  static NSUInteger FBMjpegServerFramerate = 10;
39
- static NSUInteger FBScreenshotQuality = 1;
40
- static NSUInteger FBMjpegScalingFactor = 100;
41
- static NSTimeInterval FBCustomSnapshotTimeout = 15.;
42
- static BOOL FBShouldUseFirstMatch = NO;
43
- static BOOL FBShouldBoundElementsByIndex = NO;
44
- // This is diabled by default because enabling it prevents the accessbility snapshot to be taken
45
- // (it always errors with kxIllegalArgument error)
46
- static BOOL FBIncludeNonModalElements = NO;
47
- static NSString *FBAcceptAlertButtonSelector = @"";
48
- static NSString *FBDismissAlertButtonSelector = @"";
49
- NSString *const FBSnapshotMaxDepthKey = @"maxDepth";
50
- static NSMutableDictionary *FBSnapshotRequestParameters;
51
- static NSTimeInterval FBWaitForIdleTimeout = 10.;
52
- static NSTimeInterval FBAnimationCoolOffTimeout = 2.;
53
38
 
39
+ // Session-specific settings
40
+ static BOOL FBShouldTerminateApp;
41
+ static NSUInteger FBMaxTypingFrequency;
42
+ static NSUInteger FBScreenshotQuality;
43
+ static NSTimeInterval FBCustomSnapshotTimeout;
44
+ static BOOL FBShouldUseFirstMatch;
45
+ static BOOL FBShouldBoundElementsByIndex;
46
+ static BOOL FBIncludeNonModalElements;
47
+ static NSString *FBAcceptAlertButtonSelector;
48
+ static NSString *FBDismissAlertButtonSelector;
49
+ static NSTimeInterval FBWaitForIdleTimeout;
50
+ static NSTimeInterval FBAnimationCoolOffTimeout;
51
+ static BOOL FBShouldUseCompactResponses;
52
+ static NSString *FBElementResponseAttributes;
54
53
  #if !TARGET_OS_TV
55
- static UIInterfaceOrientation FBScreenshotOrientation = UIInterfaceOrientationUnknown;
54
+ static UIInterfaceOrientation FBScreenshotOrientation;
56
55
  #endif
56
+ static NSMutableDictionary *FBSnapshotRequestParameters;
57
57
 
58
58
  @implementation FBConfiguration
59
59
 
@@ -62,9 +62,9 @@ static UIInterfaceOrientation FBScreenshotOrientation = UIInterfaceOrientationUn
62
62
  FBSnapshotRequestParameters = [NSMutableDictionary dictionaryWithDictionary:@{
63
63
  @"maxArrayCount": @INT_MAX,
64
64
  @"maxChildren": @INT_MAX,
65
- FBSnapshotMaxDepthKey: @50, // 50 should be enough for the majority of the cases. The performance is acceptable for values up to 100.
66
65
  @"traverseFromParentsToChildren": @1
67
66
  }];
67
+ [FBConfiguration resetSessionSettings];
68
68
  }
69
69
 
70
70
  #pragma mark Public
@@ -450,6 +450,30 @@ static UIInterfaceOrientation FBScreenshotOrientation = UIInterfaceOrientationUn
450
450
  }
451
451
  #endif
452
452
 
453
+ + (void)resetSessionSettings
454
+ {
455
+ FBShouldTerminateApp = YES;
456
+ FBShouldUseCompactResponses = YES;
457
+ FBElementResponseAttributes = @"type,label";
458
+ FBMaxTypingFrequency = 60;
459
+ FBScreenshotQuality = 1;
460
+ FBCustomSnapshotTimeout = 15.;
461
+ FBShouldUseFirstMatch = NO;
462
+ FBShouldBoundElementsByIndex = NO;
463
+ // This is diabled by default because enabling it prevents the accessbility snapshot to be taken
464
+ // (it always errors with kxIllegalArgument error)
465
+ FBIncludeNonModalElements = NO;
466
+ FBAcceptAlertButtonSelector = @"";
467
+ FBDismissAlertButtonSelector = @"";
468
+ FBWaitForIdleTimeout = 10.;
469
+ FBAnimationCoolOffTimeout = 2.;
470
+ // 50 should be enough for the majority of the cases. The performance is acceptable for values up to 100.
471
+ FBSnapshotRequestParameters[FBSnapshotMaxDepthKey] = @50;
472
+ #if !TARGET_OS_TV
473
+ FBScreenshotOrientation = UIInterfaceOrientationUnknown;
474
+ #endif
475
+ }
476
+
453
477
  #pragma mark Private
454
478
 
455
479
  + (FBConfigurationKeyboardPreference)keyboardsPreference:(nonnull NSString *)key
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appium-webdriveragent",
3
- "version": "4.10.2",
3
+ "version": "4.10.3",
4
4
  "description": "Package bundling WebDriverAgent",
5
5
  "main": "./build/index.js",
6
6
  "scripts": {