appium-webdriveragent 4.10.20 → 4.10.21

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,3 +1,10 @@
1
+ ## [4.10.21](https://github.com/appium/WebDriverAgent/compare/v4.10.20...v4.10.21) (2023-01-26)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Properly update maxDepth while fetching snapshots ([#655](https://github.com/appium/WebDriverAgent/issues/655)) ([6f99bab](https://github.com/appium/WebDriverAgent/commit/6f99bab5fbdbf65c9ef74c42b5f1b4c658aeaafb))
7
+
1
8
  ## [4.10.20](https://github.com/appium/WebDriverAgent/compare/v4.10.19...v4.10.20) (2023-01-17)
2
9
 
3
10
 
@@ -359,6 +359,10 @@
359
359
  714D88CD2733FB970074A925 /* FBXMLGenerationOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 714D88CA2733FB970074A925 /* FBXMLGenerationOptions.h */; };
360
360
  714D88CE2733FB970074A925 /* FBXMLGenerationOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 714D88CB2733FB970074A925 /* FBXMLGenerationOptions.m */; };
361
361
  714D88CF2733FB970074A925 /* FBXMLGenerationOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 714D88CB2733FB970074A925 /* FBXMLGenerationOptions.m */; };
362
+ 714E14B829805CAE00375DD7 /* XCAXClient_iOS+FBSnapshotReqParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 714E14B629805CAE00375DD7 /* XCAXClient_iOS+FBSnapshotReqParams.h */; };
363
+ 714E14B929805CAE00375DD7 /* XCAXClient_iOS+FBSnapshotReqParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 714E14B629805CAE00375DD7 /* XCAXClient_iOS+FBSnapshotReqParams.h */; };
364
+ 714E14BA29805CAE00375DD7 /* XCAXClient_iOS+FBSnapshotReqParams.m in Sources */ = {isa = PBXBuildFile; fileRef = 714E14B729805CAE00375DD7 /* XCAXClient_iOS+FBSnapshotReqParams.m */; };
365
+ 714E14BB29805CAE00375DD7 /* XCAXClient_iOS+FBSnapshotReqParams.m in Sources */ = {isa = PBXBuildFile; fileRef = 714E14B729805CAE00375DD7 /* XCAXClient_iOS+FBSnapshotReqParams.m */; };
362
366
  714EAA0D2673FDFE005C5B47 /* FBCapabilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 714EAA0B2673FDFE005C5B47 /* FBCapabilities.h */; };
363
367
  714EAA0E2673FDFE005C5B47 /* FBCapabilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 714EAA0B2673FDFE005C5B47 /* FBCapabilities.h */; };
364
368
  714EAA0F2673FDFE005C5B47 /* FBCapabilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 714EAA0C2673FDFE005C5B47 /* FBCapabilities.m */; };
@@ -975,6 +979,8 @@
975
979
  714CA3C61DC23186000F12C9 /* FBXPathIntegrationTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FBXPathIntegrationTests.m; sourceTree = "<group>"; };
976
980
  714D88CA2733FB970074A925 /* FBXMLGenerationOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FBXMLGenerationOptions.h; sourceTree = "<group>"; };
977
981
  714D88CB2733FB970074A925 /* FBXMLGenerationOptions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FBXMLGenerationOptions.m; sourceTree = "<group>"; };
982
+ 714E14B629805CAE00375DD7 /* XCAXClient_iOS+FBSnapshotReqParams.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "XCAXClient_iOS+FBSnapshotReqParams.h"; sourceTree = "<group>"; };
983
+ 714E14B729805CAE00375DD7 /* XCAXClient_iOS+FBSnapshotReqParams.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "XCAXClient_iOS+FBSnapshotReqParams.m"; sourceTree = "<group>"; };
978
984
  714EAA0B2673FDFE005C5B47 /* FBCapabilities.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FBCapabilities.h; sourceTree = "<group>"; };
979
985
  714EAA0C2673FDFE005C5B47 /* FBCapabilities.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FBCapabilities.m; sourceTree = "<group>"; };
980
986
  7150348521A6DAD600A0F4BA /* FBImageUtils.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FBImageUtils.h; sourceTree = "<group>"; };
@@ -1719,6 +1725,8 @@
1719
1725
  EE0D1F601EBCDCF7006A3123 /* NSString+FBVisualLength.m */,
1720
1726
  716E0BCC1E917E810087A825 /* NSString+FBXMLSafeString.h */,
1721
1727
  716E0BCD1E917E810087A825 /* NSString+FBXMLSafeString.m */,
1728
+ 714E14B629805CAE00375DD7 /* XCAXClient_iOS+FBSnapshotReqParams.h */,
1729
+ 714E14B729805CAE00375DD7 /* XCAXClient_iOS+FBSnapshotReqParams.m */,
1722
1730
  AD6C269A1CF2494200F8B5FF /* XCUIApplication+FBHelpers.h */,
1723
1731
  AD6C269B1CF2494200F8B5FF /* XCUIApplication+FBHelpers.m */,
1724
1732
  71C8E54F25399A6B008572C1 /* XCUIApplication+FBQuiescence.h */,
@@ -2284,6 +2292,7 @@
2284
2292
  641EE64B2240C5CA00173FCB /* XCTAsyncActivity.h in Headers */,
2285
2293
  641EE64C2240C5CA00173FCB /* XCTestMisuseObserver.h in Headers */,
2286
2294
  641EE64D2240C5CA00173FCB /* XCTRunnerDaemonSession.h in Headers */,
2295
+ 714E14B929805CAE00375DD7 /* XCAXClient_iOS+FBSnapshotReqParams.h in Headers */,
2287
2296
  64B2650B228CE4FF002A5025 /* FBTVNavigationTracker-Private.h in Headers */,
2288
2297
  641EE64E2240C5CA00173FCB /* FBApplication.h in Headers */,
2289
2298
  641EE64F2240C5CA00173FCB /* XCTestExpectationWaiter.h in Headers */,
@@ -2525,6 +2534,7 @@
2525
2534
  6496A5D9230D6EB30087F8CB /* AXSettings.h in Headers */,
2526
2535
  EE35AD301E3B77D600A02D78 /* XCKeyboardKeyMap.h in Headers */,
2527
2536
  EE35AD5D1E3B77D600A02D78 /* XCTNSPredicateExpectationObject-Protocol.h in Headers */,
2537
+ 714E14B829805CAE00375DD7 /* XCAXClient_iOS+FBSnapshotReqParams.h in Headers */,
2528
2538
  EE158B5F1CBD47A000A3E3F0 /* WebDriverAgentLib.h in Headers */,
2529
2539
  EE158AC01CBD456F00A3E3F0 /* FBFindElementCommands.h in Headers */,
2530
2540
  71D475C22538F5A8008D9401 /* XCUIApplicationProcess+FBQuiescence.h in Headers */,
@@ -3082,6 +3092,7 @@
3082
3092
  641EE70F2240CE4800173FCB /* FBTVNavigationTracker.m in Sources */,
3083
3093
  714D88CF2733FB970074A925 /* FBXMLGenerationOptions.m in Sources */,
3084
3094
  641EE5DE2240C5CA00173FCB /* XCUIApplication+FBTouchAction.m in Sources */,
3095
+ 714E14BB29805CAE00375DD7 /* XCAXClient_iOS+FBSnapshotReqParams.m in Sources */,
3085
3096
  641EE5DF2240C5CA00173FCB /* FBWebServer.m in Sources */,
3086
3097
  641EE5E02240C5CA00173FCB /* FBTCPSocket.m in Sources */,
3087
3098
  641EE5E12240C5CA00173FCB /* FBErrorBuilder.m in Sources */,
@@ -3260,6 +3271,7 @@
3260
3271
  EE6B64FE1D0F86EF00E85F5D /* XCTestPrivateSymbols.m in Sources */,
3261
3272
  AD76723E1D6B7CC000610457 /* XCUIElement+FBTyping.m in Sources */,
3262
3273
  EE158AAF1CBD456F00A3E3F0 /* XCUIElement+FBAccessibility.m in Sources */,
3274
+ 714E14BA29805CAE00375DD7 /* XCAXClient_iOS+FBSnapshotReqParams.m in Sources */,
3263
3275
  7150348821A6DAD600A0F4BA /* FBImageUtils.m in Sources */,
3264
3276
  E444DCAB24913C220060D7EB /* HTTPResponseProxy.m in Sources */,
3265
3277
  E444DC6D249131890060D7EB /* HTTPErrorResponse.m in Sources */,
@@ -0,0 +1,26 @@
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. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
8
+ */
9
+
10
+ #import <XCTest/XCTest.h>
11
+
12
+ #import "XCAXClient_iOS.h"
13
+
14
+ NS_ASSUME_NONNULL_BEGIN
15
+
16
+ extern NSString *const FBSnapshotMaxDepthKey;
17
+
18
+ void FBSetCustomParameterForElementSnapshot (NSString* name, id value);
19
+
20
+ id __nullable FBGetCustomParameterForElementSnapshot (NSString *name);
21
+
22
+ @interface XCAXClient_iOS (FBSnapshotReqParams)
23
+
24
+ @end
25
+
26
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,90 @@
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. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
8
+ */
9
+
10
+ #import "XCAXClient_iOS+FBSnapshotReqParams.h"
11
+
12
+ #import <objc/runtime.h>
13
+
14
+ /**
15
+ Available parameters with their default values for XCTest:
16
+ @"maxChildren" : (int)2147483647
17
+ @"traverseFromParentsToChildren" : YES
18
+ @"maxArrayCount" : (int)2147483647
19
+ @"snapshotKeyHonorModalViews" : NO
20
+ @"maxDepth" : (int)2147483647
21
+ */
22
+ NSString *const FBSnapshotMaxDepthKey = @"maxDepth";
23
+
24
+ static id (*original_defaultParameters)(id, SEL);
25
+ static id (*original_snapshotParameters)(id, SEL);
26
+ static NSDictionary *defaultRequestParameters;
27
+ static NSDictionary *defaultAdditionalRequestParameters;
28
+ static NSMutableDictionary *customRequestParameters;
29
+
30
+ void FBSetCustomParameterForElementSnapshot (NSString *name, id value)
31
+ {
32
+ static dispatch_once_t onceToken;
33
+ dispatch_once(&onceToken, ^{
34
+ customRequestParameters = [NSMutableDictionary new];
35
+ });
36
+ customRequestParameters[name] = value;
37
+ }
38
+
39
+ id FBGetCustomParameterForElementSnapshot (NSString *name)
40
+ {
41
+ return customRequestParameters[name];
42
+ }
43
+
44
+ static id swizzledDefaultParameters(id self, SEL _cmd)
45
+ {
46
+ static dispatch_once_t onceToken;
47
+ dispatch_once(&onceToken, ^{
48
+ NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:original_defaultParameters(self, _cmd)];
49
+ [params addEntriesFromDictionary:defaultAdditionalRequestParameters];
50
+ defaultRequestParameters = params.copy;
51
+ });
52
+ if (nil == defaultRequestParameters) {
53
+ return original_defaultParameters(self, _cmd);
54
+ }
55
+ NSMutableDictionary *result = [NSMutableDictionary dictionaryWithDictionary:defaultRequestParameters];
56
+ if (nil != customRequestParameters && customRequestParameters.count > 0) {
57
+ [result addEntriesFromDictionary:customRequestParameters];
58
+ }
59
+ return result.copy;
60
+ }
61
+
62
+ static id swizzledSnapshotParameters(id self, SEL _cmd)
63
+ {
64
+ NSDictionary *result = original_snapshotParameters(self, _cmd);
65
+ if (nil == defaultAdditionalRequestParameters) {
66
+ defaultAdditionalRequestParameters = result;
67
+ }
68
+ return result;
69
+ }
70
+
71
+
72
+ @implementation XCAXClient_iOS (FBSnapshotReqParams)
73
+
74
+ #pragma clang diagnostic push
75
+ #pragma clang diagnostic ignored "-Wobjc-load-method"
76
+
77
+ + (void)load
78
+ {
79
+ Method original_defaultParametersMethod = class_getInstanceMethod(self.class, @selector(defaultParameters));
80
+ IMP swizzledDefaultParametersImp = (IMP)swizzledDefaultParameters;
81
+ original_defaultParameters = (id (*)(id, SEL)) method_setImplementation(original_defaultParametersMethod, swizzledDefaultParametersImp);
82
+
83
+ Method original_snapshotParametersMethod = class_getInstanceMethod(NSClassFromString(@"XCTElementQuery"), NSSelectorFromString(@"snapshotParameters"));
84
+ IMP swizzledSnapshotParametersImp = (IMP)swizzledSnapshotParameters;
85
+ original_snapshotParameters = (id (*)(id, SEL)) method_setImplementation(original_snapshotParametersMethod, swizzledSnapshotParametersImp);
86
+ }
87
+
88
+ #pragma clang diagnostic pop
89
+
90
+ @end
@@ -183,13 +183,6 @@ typedef NS_ENUM(NSInteger, FBConfigurationKeyboardPreference) {
183
183
  */
184
184
  + (int)snapshotMaxDepth;
185
185
 
186
- /**
187
- Returns parameters for traversing elements tree from parents to children while requesting XCElementSnapshot.
188
-
189
- @return dictionary with parameters for element's snapshot request
190
- */
191
- + (NSDictionary *)snapshotRequestParameters;
192
-
193
186
  /**
194
187
  * Whether to use fast search result matching while searching for elements.
195
188
  * By default this is disabled due to https://github.com/appium/appium/issues/10101
@@ -14,6 +14,7 @@
14
14
 
15
15
  #include "TargetConditionals.h"
16
16
  #import "FBXCodeCompatibility.h"
17
+ #import "XCAXClient_iOS+FBSnapshotReqParams.h"
17
18
  #import "XCTestPrivateSymbols.h"
18
19
  #import "XCTestConfiguration.h"
19
20
  #import "XCUIApplication+FBUIInterruptions.h"
@@ -30,7 +31,6 @@ static NSString *const axSettingsClassName = @"AXSettings";
30
31
 
31
32
  static BOOL FBShouldUseTestManagerForVisibilityDetection = NO;
32
33
  static BOOL FBShouldUseSingletonTestManager = YES;
33
- NSString *const FBSnapshotMaxDepthKey = @"maxDepth";
34
34
 
35
35
  static NSUInteger FBMjpegScalingFactor = 100;
36
36
  static NSUInteger FBMjpegServerScreenshotQuality = 25;
@@ -53,17 +53,11 @@ static NSString *FBElementResponseAttributes;
53
53
  #if !TARGET_OS_TV
54
54
  static UIInterfaceOrientation FBScreenshotOrientation;
55
55
  #endif
56
- static NSMutableDictionary *FBSnapshotRequestParameters;
57
56
 
58
57
  @implementation FBConfiguration
59
58
 
60
59
  + (void)initialize
61
60
  {
62
- FBSnapshotRequestParameters = [NSMutableDictionary dictionaryWithDictionary:@{
63
- @"maxArrayCount": @INT_MAX,
64
- @"maxChildren": @INT_MAX,
65
- @"traverseFromParentsToChildren": @1
66
- }];
67
61
  [FBConfiguration resetSessionSettings];
68
62
  }
69
63
 
@@ -341,17 +335,12 @@ static NSMutableDictionary *FBSnapshotRequestParameters;
341
335
 
342
336
  + (void)setSnapshotMaxDepth:(int)maxDepth
343
337
  {
344
- FBSnapshotRequestParameters[FBSnapshotMaxDepthKey] = @(maxDepth);
338
+ FBSetCustomParameterForElementSnapshot(FBSnapshotMaxDepthKey, @(maxDepth));
345
339
  }
346
340
 
347
341
  + (int)snapshotMaxDepth
348
342
  {
349
- return [FBSnapshotRequestParameters[FBSnapshotMaxDepthKey] intValue];
350
- }
351
-
352
- + (NSDictionary *)snapshotRequestParameters
353
- {
354
- return FBSnapshotRequestParameters;
343
+ return [FBGetCustomParameterForElementSnapshot(FBSnapshotMaxDepthKey) intValue];
355
344
  }
356
345
 
357
346
  + (void)setUseFirstMatch:(BOOL)enabled
@@ -468,7 +457,7 @@ static NSMutableDictionary *FBSnapshotRequestParameters;
468
457
  FBWaitForIdleTimeout = 10.;
469
458
  FBAnimationCoolOffTimeout = 2.;
470
459
  // 50 should be enough for the majority of the cases. The performance is acceptable for values up to 100.
471
- FBSnapshotRequestParameters[FBSnapshotMaxDepthKey] = @50;
460
+ FBSetCustomParameterForElementSnapshot(FBSnapshotMaxDepthKey, @50);
472
461
  #if !TARGET_OS_TV
473
462
  FBScreenshotOrientation = UIInterfaceOrientationUnknown;
474
463
  #endif
@@ -9,47 +9,14 @@
9
9
 
10
10
  #import "FBXCAXClientProxy.h"
11
11
 
12
- #import <objc/runtime.h>
13
-
14
12
  #import "FBXCAccessibilityElement.h"
15
- #import "FBConfiguration.h"
16
13
  #import "FBLogger.h"
17
14
  #import "FBMacros.h"
18
- #import "FBReflectionUtils.h"
19
- #import "XCAXClient_iOS.h"
15
+ #import "XCAXClient_iOS+FBSnapshotReqParams.h"
20
16
  #import "XCUIDevice.h"
21
17
 
22
18
  static id FBAXClient = nil;
23
19
 
24
- @implementation XCAXClient_iOS (WebDriverAgent)
25
-
26
- /**
27
- Parameters for traversing elements tree from parents to children while requesting XCElementSnapshot.
28
-
29
- @return dictionary with parameters for element's snapshot request
30
- */
31
- - (NSDictionary *)fb_getParametersForElementSnapshot
32
- {
33
- return FBConfiguration.snapshotRequestParameters;
34
- }
35
-
36
- #pragma clang diagnostic push
37
- #pragma clang diagnostic ignored "-Wobjc-load-method"
38
-
39
- + (void)load
40
- {
41
- static dispatch_once_t onceToken;
42
- dispatch_once(&onceToken, ^{
43
- SEL originalParametersSelector = @selector(defaultParameters);
44
- SEL swizzledParametersSelector = @selector(fb_getParametersForElementSnapshot);
45
- FBReplaceMethod([self class], originalParametersSelector, swizzledParametersSelector);
46
- });
47
- }
48
-
49
- #pragma clang diagnostic pop
50
-
51
- @end
52
-
53
20
  @implementation FBXCAXClientProxy
54
21
 
55
22
  + (instancetype)sharedClient
@@ -73,14 +40,8 @@ static id FBAXClient = nil;
73
40
  maxDepth:(nullable NSNumber *)maxDepth
74
41
  error:(NSError **)error
75
42
  {
76
- NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
77
- // Mimicking XCTest framework behavior (this attribute is added by default unless it is an excludingNonModalElements query)
78
- // See https://github.com/appium/WebDriverAgent/pull/523
79
- if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"13.0")) {
80
- parameters[@"snapshotKeyHonorModalViews"] = @(NO);
81
- }
43
+ NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithDictionary:self.defaultParameters];
82
44
  if (nil != maxDepth) {
83
- [parameters addEntriesFromDictionary:self.defaultParameters];
84
45
  parameters[FBSnapshotMaxDepthKey] = maxDepth;
85
46
  }
86
47
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appium-webdriveragent",
3
- "version": "4.10.20",
3
+ "version": "4.10.21",
4
4
  "description": "Package bundling WebDriverAgent",
5
5
  "main": "./build/index.js",
6
6
  "scripts": {