appium-webdriveragent 5.7.0 → 5.8.0

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
+ ## [5.8.0](https://github.com/appium/WebDriverAgent/compare/v5.7.0...v5.8.0) (2023-08-24)
2
+
3
+
4
+ ### Features
5
+
6
+ * Add wdHittable property ([#756](https://github.com/appium/WebDriverAgent/issues/756)) ([075298b](https://github.com/appium/WebDriverAgent/commit/075298b286c83ab5d4a2855e9e0bb915790b3f43))
7
+
1
8
  ## [5.7.0](https://github.com/appium/WebDriverAgent/compare/v5.6.2...v5.7.0) (2023-08-24)
2
9
 
3
10
 
@@ -20,6 +20,7 @@
20
20
  #import "XCUIElement+FBUtilities.h"
21
21
  #import "FBElementUtils.h"
22
22
  #import "XCTestPrivateSymbols.h"
23
+ #import "XCUIHitPointResult.h"
23
24
 
24
25
  #define BROKEN_RECT CGRectMake(-1, -1, 0, 0)
25
26
 
@@ -226,6 +227,12 @@
226
227
  return 0;
227
228
  }
228
229
 
230
+ - (BOOL)isWDHittable
231
+ {
232
+ XCUIHitPointResult *result = [self hitPoint:nil];
233
+ return nil == result ? NO : result.hittable;
234
+ }
235
+
229
236
  - (NSDictionary *)wdRect
230
237
  {
231
238
  CGRect frame = self.wdFrame;
@@ -56,6 +56,9 @@ NS_ASSUME_NONNULL_BEGIN
56
56
  /*! Whether element is focused */
57
57
  @property (nonatomic, readonly, getter = isWDFocused) BOOL wdFocused;
58
58
 
59
+ /*! Whether element is hittable */
60
+ @property (nonatomic, readonly, getter = isWDHittable) BOOL wdHittable;
61
+
59
62
  /*! Element's index relatively to its parent. Starts from zero */
60
63
  @property (nonatomic, readonly) NSUInteger wdIndex;
61
64
 
@@ -52,3 +52,7 @@
52
52
 
53
53
  /*! Converts the given number of milliseconds into seconds */
54
54
  #define FBMillisToSeconds(ms) ((ms) / 1000.0)
55
+
56
+ /*! Converts boolean value to its string representation */
57
+ #define FBBoolToString(b) ((b) ? @"true" : @"false")
58
+
@@ -12,6 +12,7 @@
12
12
  #import "FBConfiguration.h"
13
13
  #import "FBExceptions.h"
14
14
  #import "FBLogger.h"
15
+ #import "FBMacros.h"
15
16
  #import "FBXMLGenerationOptions.h"
16
17
  #import "FBXCElementSnapshotWrapper+Helpers.h"
17
18
  #import "NSString+FBXMLSafeString.h"
@@ -87,6 +88,10 @@
87
88
 
88
89
  @end
89
90
 
91
+ @interface FBHittableAttribute : FBElementAttribute
92
+
93
+ @end
94
+
90
95
  @interface FBInternalIndexAttribute : FBElementAttribute
91
96
 
92
97
  @property (nonatomic, nonnull, readonly) NSString* indexValue;
@@ -273,6 +278,9 @@ static NSString *const topNodeIndexPath = @"top";
273
278
  NSMutableSet<Class> *includedAttributes;
274
279
  if (nil == query) {
275
280
  includedAttributes = [NSMutableSet setWithArray:FBElementAttribute.supportedAttributes];
281
+ // The hittable attribute is expensive to calculate for each snapshot item
282
+ // thus we only include it when requested by an xPath query
283
+ [includedAttributes removeObject:FBHittableAttribute.class];
276
284
  if (nil != excludedAttributes) {
277
285
  for (NSString *excludedAttributeName in excludedAttributes) {
278
286
  for (Class supportedAttribute in FBElementAttribute.supportedAttributes) {
@@ -481,6 +489,7 @@ static NSString *const FBAbstractMethodInvocationException = @"AbstractMethodInv
481
489
  FBWidthAttribute.class,
482
490
  FBHeightAttribute.class,
483
491
  FBIndexAttribute.class,
492
+ FBHittableAttribute.class,
484
493
  ];
485
494
  }
486
495
 
@@ -557,7 +566,7 @@ static NSString *const FBAbstractMethodInvocationException = @"AbstractMethodInv
557
566
 
558
567
  + (NSString *)valueForElement:(id<FBElement>)element
559
568
  {
560
- return element.wdEnabled ? @"true" : @"false";
569
+ return FBBoolToString(element.wdEnabled);
561
570
  }
562
571
 
563
572
  @end
@@ -571,7 +580,7 @@ static NSString *const FBAbstractMethodInvocationException = @"AbstractMethodInv
571
580
 
572
581
  + (NSString *)valueForElement:(id<FBElement>)element
573
582
  {
574
- return element.wdVisible ? @"true" : @"false";
583
+ return FBBoolToString(element.wdVisible);
575
584
  }
576
585
 
577
586
  @end
@@ -585,7 +594,7 @@ static NSString *const FBAbstractMethodInvocationException = @"AbstractMethodInv
585
594
 
586
595
  + (NSString *)valueForElement:(id<FBElement>)element
587
596
  {
588
- return element.wdAccessible ? @"true" : @"false";
597
+ return FBBoolToString(element.wdAccessible);
589
598
  }
590
599
 
591
600
  @end
@@ -601,7 +610,7 @@ static NSString *const FBAbstractMethodInvocationException = @"AbstractMethodInv
601
610
 
602
611
  + (NSString *)valueForElement:(id<FBElement>)element
603
612
  {
604
- return element.wdFocused ? @"true" : @"false";
613
+ return FBBoolToString(element.wdFocused);
605
614
  }
606
615
 
607
616
  @end
@@ -667,6 +676,20 @@ static NSString *const FBAbstractMethodInvocationException = @"AbstractMethodInv
667
676
 
668
677
  @end
669
678
 
679
+ @implementation FBHittableAttribute
680
+
681
+ + (NSString *)name
682
+ {
683
+ return @"hittable";
684
+ }
685
+
686
+ + (NSString *)valueForElement:(id<FBElement>)element
687
+ {
688
+ return FBBoolToString(element.wdHittable);
689
+ }
690
+
691
+ @end
692
+
670
693
  @implementation FBInternalIndexAttribute
671
694
 
672
695
  + (NSString *)name
@@ -160,6 +160,7 @@
160
160
  XCTAssertNil(element.wdLabel);
161
161
  XCTAssertEqualObjects(element.wdValue, @"1");
162
162
  XCTAssertFalse(element.wdSelected);
163
+ XCTAssertTrue(element.wdHittable);
163
164
  [element tap];
164
165
  XCTAssertEqualObjects(element.wdValue, @"0");
165
166
  XCTAssertFalse(element.wdSelected);
@@ -10,6 +10,7 @@
10
10
  #import <XCTest/XCTest.h>
11
11
 
12
12
  #import "FBIntegrationTestCase.h"
13
+ #import "FBMacros.h"
13
14
  #import "FBTestMacros.h"
14
15
  #import "FBXPath.h"
15
16
  #import "FBXCodeCompatibility.h"
@@ -58,7 +59,7 @@
58
59
  NSString *xmlStr = [FBXPath xmlStringWithRootElement:wrappedSnapshot
59
60
  options:nil];
60
61
  XCTAssertNotNil(xmlStr);
61
- NSString *expectedXml = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<%@ type=\"%@\" name=\"%@\" label=\"%@\" enabled=\"%@\" visible=\"%@\" accessible=\"%@\" x=\"%@\" y=\"%@\" width=\"%@\" height=\"%@\" index=\"%lu\"/>\n", wrappedSnapshot.wdType, wrappedSnapshot.wdType, wrappedSnapshot.wdName, wrappedSnapshot.wdLabel, wrappedSnapshot.wdEnabled ? @"true" : @"false", wrappedSnapshot.wdVisible ? @"true" : @"false", wrappedSnapshot.wdAccessible ? @"true" : @"false", [wrappedSnapshot.wdRect[@"x"] stringValue], [wrappedSnapshot.wdRect[@"y"] stringValue], [wrappedSnapshot.wdRect[@"width"] stringValue], [wrappedSnapshot.wdRect[@"height"] stringValue], wrappedSnapshot.wdIndex];
62
+ NSString *expectedXml = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<%@ type=\"%@\" name=\"%@\" label=\"%@\" enabled=\"%@\" visible=\"%@\" accessible=\"%@\" x=\"%@\" y=\"%@\" width=\"%@\" height=\"%@\" index=\"%lu\"/>\n", wrappedSnapshot.wdType, wrappedSnapshot.wdType, wrappedSnapshot.wdName, wrappedSnapshot.wdLabel, FBBoolToString(wrappedSnapshot.wdEnabled), FBBoolToString(wrappedSnapshot.wdVisible), FBBoolToString(wrappedSnapshot.wdAccessible), [wrappedSnapshot.wdRect[@"x"] stringValue], [wrappedSnapshot.wdRect[@"y"] stringValue], [wrappedSnapshot.wdRect[@"width"] stringValue], [wrappedSnapshot.wdRect[@"height"] stringValue], wrappedSnapshot.wdIndex];
62
63
  XCTAssertEqualObjects(xmlStr, expectedXml);
63
64
  }
64
65
 
@@ -71,7 +72,7 @@
71
72
  NSString *xmlStr = [FBXPath xmlStringWithRootElement:wrappedSnapshot
72
73
  options:options];
73
74
  XCTAssertNotNil(xmlStr);
74
- NSString *expectedXml = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<%@>\n <%@ type=\"%@\" name=\"%@\" label=\"%@\" enabled=\"%@\" visible=\"%@\" accessible=\"%@\" x=\"%@\" y=\"%@\" width=\"%@\" height=\"%@\" index=\"%lu\"/>\n</%@>\n", scope, wrappedSnapshot.wdType, wrappedSnapshot.wdType, wrappedSnapshot.wdName, wrappedSnapshot.wdLabel, wrappedSnapshot.wdEnabled ? @"true" : @"false", wrappedSnapshot.wdVisible ? @"true" : @"false", wrappedSnapshot.wdAccessible ? @"true" : @"false", [wrappedSnapshot.wdRect[@"x"] stringValue], [wrappedSnapshot.wdRect[@"y"] stringValue], [wrappedSnapshot.wdRect[@"width"] stringValue], [wrappedSnapshot.wdRect[@"height"] stringValue], wrappedSnapshot.wdIndex, scope];
75
+ NSString *expectedXml = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<%@>\n <%@ type=\"%@\" name=\"%@\" label=\"%@\" enabled=\"%@\" visible=\"%@\" accessible=\"%@\" x=\"%@\" y=\"%@\" width=\"%@\" height=\"%@\" index=\"%lu\"/>\n</%@>\n", scope, wrappedSnapshot.wdType, wrappedSnapshot.wdType, wrappedSnapshot.wdName, wrappedSnapshot.wdLabel, FBBoolToString(wrappedSnapshot.wdEnabled), FBBoolToString(wrappedSnapshot.wdVisible), FBBoolToString(wrappedSnapshot.wdAccessible), [wrappedSnapshot.wdRect[@"x"] stringValue], [wrappedSnapshot.wdRect[@"y"] stringValue], [wrappedSnapshot.wdRect[@"width"] stringValue], [wrappedSnapshot.wdRect[@"height"] stringValue], wrappedSnapshot.wdIndex, scope];
75
76
  XCTAssertEqualObjects(xmlStr, expectedXml);
76
77
  }
77
78
 
@@ -84,7 +85,7 @@
84
85
  NSString *xmlStr = [FBXPath xmlStringWithRootElement:wrappedSnapshot
85
86
  options:options];
86
87
  XCTAssertNotNil(xmlStr);
87
- NSString *expectedXml = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<%@ type=\"%@\" name=\"%@\" label=\"%@\" accessible=\"%@\" x=\"%@\" y=\"%@\" width=\"%@\" height=\"%@\"/>\n", wrappedSnapshot.wdType, wrappedSnapshot.wdType, wrappedSnapshot.wdName, wrappedSnapshot.wdLabel, wrappedSnapshot.wdAccessible ? @"true" : @"false", [wrappedSnapshot.wdRect[@"x"] stringValue], [wrappedSnapshot.wdRect[@"y"] stringValue], [wrappedSnapshot.wdRect[@"width"] stringValue], [wrappedSnapshot.wdRect[@"height"] stringValue]];
88
+ NSString *expectedXml = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<%@ type=\"%@\" name=\"%@\" label=\"%@\" accessible=\"%@\" x=\"%@\" y=\"%@\" width=\"%@\" height=\"%@\"/>\n", wrappedSnapshot.wdType, wrappedSnapshot.wdType, wrappedSnapshot.wdName, wrappedSnapshot.wdLabel, FBBoolToString(wrappedSnapshot.wdAccessible), [wrappedSnapshot.wdRect[@"x"] stringValue], [wrappedSnapshot.wdRect[@"y"] stringValue], [wrappedSnapshot.wdRect[@"width"] stringValue], [wrappedSnapshot.wdRect[@"height"] stringValue]];
88
89
  XCTAssertEqualObjects(xmlStr, expectedXml);
89
90
  }
90
91
 
@@ -127,7 +127,7 @@
127
127
 
128
128
  - (void)testSingleDescendantWithXPathQuery
129
129
  {
130
- NSArray<XCUIElement *> *matchingSnapshots = [self.testedApplication fb_descendantsMatchingXPathQuery:@"//XCUIElementTypeButton"
130
+ NSArray<XCUIElement *> *matchingSnapshots = [self.testedApplication fb_descendantsMatchingXPathQuery:@"//XCUIElementTypeButton[@hittable='true']"
131
131
  shouldReturnAfterFirstMatch:YES];
132
132
  XCTAssertEqual(matchingSnapshots.count, 1);
133
133
  XCUIElement *matchingSnapshot = [matchingSnapshots firstObject];
@@ -11,6 +11,7 @@
11
11
 
12
12
  #import "FBXCAccessibilityElement.h"
13
13
  #import "FBXCElementSnapshot.h"
14
+ #import "XCUIHitPointResult.h"
14
15
 
15
16
  @implementation XCElementSnapshotDouble
16
17
 
@@ -87,6 +88,11 @@
87
88
  return nil;
88
89
  }
89
90
 
91
+ - (XCUIHitPointResult *)hitPoint:(NSError **)error
92
+ {
93
+ return [[XCUIHitPointResult alloc] initWithHitPoint:CGPointZero hittable:YES];
94
+ }
95
+
90
96
  - (NSArray *)children
91
97
  {
92
98
  return @[];
@@ -32,6 +32,8 @@
32
32
  @property (nonatomic, readwrite) NSUInteger wdIndex;
33
33
  @property (nonatomic, readwrite, getter=isWDVisible) BOOL wdVisible;
34
34
  @property (nonatomic, readwrite, getter=isWDAccessible) BOOL wdAccessible;
35
+ @property (nonatomic, readwrite, getter = isWDFocused) BOOL wdFocused;
36
+ @property (nonatomic, readwrite, getter = isWDHittable) BOOL wdHittable;
35
37
  @property (copy, nonnull) NSArray *children;
36
38
  @property (nonatomic, readwrite, assign) XCUIElementType elementType;
37
39
  @property (nonatomic, readwrite, getter=isWDAccessibilityContainer) BOOL wdAccessibilityContainer;
@@ -27,6 +27,8 @@
27
27
  self.wdAccessible = YES;
28
28
  self.wdEnabled = YES;
29
29
  self.wdSelected = YES;
30
+ self.wdFocused = YES;
31
+ self.wdHittable = YES;
30
32
  self.wdIndex = 0;
31
33
  #if TARGET_OS_TV
32
34
  self.wdFocused = YES;
@@ -9,6 +9,7 @@
9
9
 
10
10
  #import <XCTest/XCTest.h>
11
11
 
12
+ #import "FBMacros.h"
12
13
  #import "FBXPath.h"
13
14
  #import "FBXPath-Private.h"
14
15
  #import "XCUIElementDouble.h"
@@ -63,7 +64,7 @@
63
64
  xpathQuery:nil
64
65
  excludingAttributes:nil];
65
66
  NSString *expectedXml = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<%@ type=\"%@\" value=\"%@\" name=\"%@\" label=\"%@\" enabled=\"%@\" visible=\"%@\" accessible=\"%@\" x=\"%@\" y=\"%@\" width=\"%@\" height=\"%@\" index=\"%lu\" private_indexPath=\"top\"/>\n",
66
- element.wdType, element.wdType, element.wdValue, element.wdName, element.wdLabel, element.wdEnabled ? @"true" : @"false", element.wdVisible ? @"true" : @"false", element.wdAccessible ? @"true" : @"false", element.wdRect[@"x"], element.wdRect[@"y"], element.wdRect[@"width"], element.wdRect[@"height"], element.wdIndex];
67
+ element.wdType, element.wdType, element.wdValue, element.wdName, element.wdLabel, FBBoolToString(element.wdEnabled), FBBoolToString(element.wdVisible), FBBoolToString(element.wdAccessible), element.wdRect[@"x"], element.wdRect[@"y"], element.wdRect[@"width"], element.wdRect[@"height"], element.wdIndex];
67
68
  XCTAssertTrue([resultXml isEqualToString: expectedXml]);
68
69
  }
69
70
 
@@ -75,7 +76,7 @@
75
76
  xpathQuery:nil
76
77
  excludingAttributes:@[@"type", @"visible", @"value", @"index"]];
77
78
  NSString *expectedXml = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<%@ name=\"%@\" label=\"%@\" enabled=\"%@\" accessible=\"%@\" x=\"%@\" y=\"%@\" width=\"%@\" height=\"%@\" private_indexPath=\"top\"/>\n",
78
- element.wdType, element.wdName, element.wdLabel, element.wdEnabled ? @"true" : @"false", element.wdAccessible ? @"true" : @"false", element.wdRect[@"x"], element.wdRect[@"y"], element.wdRect[@"width"], element.wdRect[@"height"]];
79
+ element.wdType, element.wdName, element.wdLabel, FBBoolToString(element.wdEnabled), FBBoolToString(element.wdAccessible), element.wdRect[@"x"], element.wdRect[@"y"], element.wdRect[@"width"], element.wdRect[@"height"]];
79
80
  XCTAssertEqualObjects(resultXml, expectedXml);
80
81
  }
81
82
 
@@ -88,9 +89,9 @@
88
89
  NSString *resultXml = [self xmlStringWithElement:element
89
90
  xpathQuery:[NSString stringWithFormat:@"//%@[@*]", element.wdType]
90
91
  excludingAttributes:@[@"visible"]];
91
- NSString *expectedXml = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<%@ type=\"%@\" value=\"%@\" name=\"%@\" label=\"%@\" enabled=\"%@\" visible=\"%@\" accessible=\"%@\" x=\"%@\" y=\"%@\" width=\"%@\" height=\"%@\" index=\"%lu\" private_indexPath=\"top\"/>\n",
92
- element.wdType, element.wdType, @"йоло&lt;&gt;&amp;&quot;", element.wdName, @"a&#10;b", element.wdEnabled ? @"true" : @"false", element.wdVisible ? @"true" : @"false", element.wdAccessible ? @"true" : @"false", element.wdRect[@"x"], element.wdRect[@"y"], element.wdRect[@"width"], element.wdRect[@"height"], element.wdIndex];
93
- XCTAssertTrue([resultXml isEqualToString:expectedXml]);
92
+ NSString *expectedXml = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<%@ type=\"%@\" value=\"%@\" name=\"%@\" label=\"%@\" enabled=\"%@\" visible=\"%@\" accessible=\"%@\" x=\"%@\" y=\"%@\" width=\"%@\" height=\"%@\" index=\"%lu\" hittable=\"%@\" private_indexPath=\"top\"/>\n",
93
+ element.wdType, element.wdType, @"йоло&lt;&gt;&amp;&quot;", element.wdName, @"a&#10;b", FBBoolToString(element.wdEnabled), FBBoolToString(element.wdVisible), FBBoolToString(element.wdAccessible), element.wdRect[@"x"], element.wdRect[@"y"], element.wdRect[@"width"], element.wdRect[@"height"], element.wdIndex, FBBoolToString(element.wdHittable)];
94
+ XCTAssertEqualObjects(expectedXml, resultXml);
94
95
  }
95
96
 
96
97
  - (void)testXPathPresentationBasedOnQueryMatchingSomeAttributes
@@ -32,6 +32,7 @@
32
32
  @property (nonatomic, readwrite, getter=isWDVisible) BOOL wdVisible;
33
33
  @property (nonatomic, readwrite, getter=isWDAccessible) BOOL wdAccessible;
34
34
  @property (nonatomic, readwrite, getter=isWDFocused) BOOL wdFocused;
35
+ @property (nonatomic, readwrite, getter = isWDHittable) BOOL wdHittable;
35
36
  @property (copy, nonnull) NSArray *children;
36
37
  @property (nonatomic, readwrite, assign) XCUIElementType elementType;
37
38
  @property (nonatomic, readwrite, getter=isWDAccessibilityContainer) BOOL wdAccessibilityContainer;
@@ -27,6 +27,7 @@
27
27
  self.wdAccessible = YES;
28
28
  self.wdEnabled = YES;
29
29
  self.wdSelected = YES;
30
+ self.wdHittable = YES;
30
31
  self.wdIndex = 0;
31
32
  #if TARGET_OS_TV
32
33
  self.wdFocused = YES;
@@ -8,5 +8,5 @@ export const SDK_SIMULATOR: "iphonesimulator";
8
8
  export const SDK_DEVICE: "iphoneos";
9
9
  export const WDA_BASE_URL: "http://127.0.0.1";
10
10
  export const WDA_UPGRADE_TIMESTAMP_PATH: string;
11
- export const WDA_RUNNER_BUNDLE_ID_FOR_XCTEST: string;
11
+ export const WDA_RUNNER_BUNDLE_ID_FOR_XCTEST: "com.facebook.WebDriverAgentRunner.xctrunner";
12
12
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../lib/constants.js"],"names":[],"mappings":"AAEA,uEAAiE;AAEjE,+DAAyD;AAEzD,6CAAuC;AADvC,gDAA0C;AAI1C,wCAAkC;AAClC,sCAAgC;AAEhC,8CAAwC;AACxC,oCAA8B;AAN9B,8CAAwC;AAQxC,gDAA0F;AAZ1F,qDAA4E"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../lib/constants.js"],"names":[],"mappings":"AAEA,uEAAiE;AAEjE,+DAAyD;AAEzD,6CAAuC;AADvC,gDAA0C;AAI1C,wCAAkC;AAClC,sCAAgC;AAEhC,8CAAwC;AACxC,oCAA8B;AAN9B,8CAAwC;AAQxC,gDAA0F;AAZ1F,4FAA4E"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appium-webdriveragent",
3
- "version": "5.7.0",
3
+ "version": "5.8.0",
4
4
  "description": "Package bundling WebDriverAgent",
5
5
  "main": "./build/index.js",
6
6
  "scripts": {