appium-webdriveragent 4.12.2 → 4.13.1

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,17 @@
1
+ ## [4.13.1](https://github.com/appium/WebDriverAgent/compare/v4.13.0...v4.13.1) (2023-04-04)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Fixed Xpath lookup for Xcode 14.3 ([#681](https://github.com/appium/WebDriverAgent/issues/681)) ([3e0b191](https://github.com/appium/WebDriverAgent/commit/3e0b1914f87585ed69ba20d960502eabb058941c))
7
+
8
+ ## [4.13.0](https://github.com/appium/WebDriverAgent/compare/v4.12.2...v4.13.0) (2023-02-23)
9
+
10
+
11
+ ### Features
12
+
13
+ * Increase Xpath Lookup Performance ([#666](https://github.com/appium/WebDriverAgent/issues/666)) ([1696f4b](https://github.com/appium/WebDriverAgent/commit/1696f4bb879152ef04408940849708654072c797))
14
+
1
15
  ## [4.12.2](https://github.com/appium/WebDriverAgent/compare/v4.12.1...v4.12.2) (2023-02-22)
2
16
 
3
17
 
@@ -47,9 +47,7 @@ static char XCUIELEMENT_IS_RESOLVED_NATIVELY_KEY;
47
47
  if (nil == uid) {
48
48
  return self;
49
49
  }
50
- NSPredicate *predicate = [NSPredicate predicateWithBlock:^BOOL(id<FBXCElementSnapshot> snapshot, NSDictionary *bindings) {
51
- return [[FBXCElementSnapshotWrapper wdUIDWithSnapshot:snapshot] isEqualToString:uid];
52
- }];
50
+ NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%K = %@",FBStringify(FBXCElementSnapshotWrapper, fb_uid), uid];
53
51
  return [query matchingPredicate:predicate].allElementsBoundByIndex.firstObject ?: self;
54
52
  }
55
53
 
@@ -7,9 +7,12 @@
7
7
  * of patent rights can be found in the PATENTS file in the same directory.
8
8
  */
9
9
 
10
+ #import <objc/runtime.h>
11
+
10
12
  #import "XCUIElement+FBUID.h"
11
13
 
12
14
  #import "FBElementUtils.h"
15
+ #import "FBLogger.h"
13
16
  #import "XCUIApplication.h"
14
17
  #import "XCUIElement+FBUtilities.h"
15
18
 
@@ -33,6 +36,34 @@
33
36
 
34
37
  @implementation FBXCElementSnapshotWrapper (FBUID)
35
38
 
39
+ static void swizzled_validatePredicateWithExpressionsAllowed(id self, SEL _cmd, id predicate, BOOL withExpressionsAllowed)
40
+ {
41
+ }
42
+
43
+ #pragma clang diagnostic push
44
+ #pragma clang diagnostic ignored "-Wobjc-load-method"
45
+ + (void)load
46
+ {
47
+ Class XCElementSnapshotCls = objc_lookUpClass("XCElementSnapshot");
48
+ NSAssert(XCElementSnapshotCls != nil, @"Could not locate XCElementSnapshot class");
49
+ Method uidMethod = class_getInstanceMethod(self.class, @selector(fb_uid));
50
+ class_addMethod(XCElementSnapshotCls, @selector(fb_uid), method_getImplementation(uidMethod), method_getTypeEncoding(uidMethod));
51
+
52
+ // Support for Xcode 14.3 requires disabling the new predicate validator, see https://github.com/appium/appium/issues/18444
53
+ Class XCTElementQueryTransformerPredicateValidatorCls = objc_lookUpClass("XCTElementQueryTransformerPredicateValidator");
54
+ if (XCTElementQueryTransformerPredicateValidatorCls == nil) {
55
+ return;
56
+ }
57
+ Method validatePredicateMethod = class_getClassMethod(XCTElementQueryTransformerPredicateValidatorCls, NSSelectorFromString(@"validatePredicate:withExpressionsAllowed:"));
58
+ if (validatePredicateMethod == nil) {
59
+ [FBLogger log:@"Could not find method +[XCTElementQueryTransformerPredicateValidator validatePredicate:withExpressionsAllowed:]"];
60
+ return;
61
+ }
62
+ IMP swizzledImp = (IMP)swizzled_validatePredicateWithExpressionsAllowed;
63
+ method_setImplementation(validatePredicateMethod, swizzledImp);
64
+ }
65
+ #pragma diagnostic pop
66
+
36
67
  - (unsigned long long)fb_accessibiltyId
37
68
  {
38
69
  return [FBElementUtils idWithAccessibilityElement:self.accessibilityElement];
@@ -45,7 +76,10 @@
45
76
 
46
77
  - (NSString *)fb_uid
47
78
  {
48
- return [self.class wdUIDWithSnapshot:self.snapshot];
79
+ if ([self isKindOfClass:FBXCElementSnapshotWrapper.class]) {
80
+ return [self.class wdUIDWithSnapshot:self.snapshot];
81
+ }
82
+ return [FBElementUtils uidWithAccessibilityElement:[self accessibilityElement]];
49
83
  }
50
84
 
51
85
  @end
@@ -162,10 +162,10 @@
162
162
  XCUIElementQuery *query = onlyChildren
163
163
  ? [self.fb_query childrenMatchingType:type]
164
164
  : [self.fb_query descendantsMatchingType:type];
165
- NSPredicate *predicate = [NSPredicate predicateWithBlock:^BOOL(id<FBXCElementSnapshot> snapshot, NSDictionary *bindings) {
166
- return [matchedIds containsObject:[FBXCElementSnapshotWrapper wdUIDWithSnapshot:snapshot] ?: @""];
167
- }];
165
+
166
+ NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%K IN %@",FBStringify(FBXCElementSnapshotWrapper, fb_uid), matchedIds];
168
167
  [matchedElements addObjectsFromArray:[query matchingPredicate:predicate].allElementsBoundByIndex];
168
+
169
169
  for (XCUIElement *el in matchedElements) {
170
170
  el.fb_isResolvedNatively = @NO;
171
171
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appium-webdriveragent",
3
- "version": "4.12.2",
3
+ "version": "4.13.1",
4
4
  "description": "Package bundling WebDriverAgent",
5
5
  "main": "./build/index.js",
6
6
  "scripts": {