appium-webdriveragent 4.7.0 → 4.8.2

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.
Files changed (101) hide show
  1. package/PrivateHeaders/XCTest/XCAXClient_iOS.h +2 -4
  2. package/PrivateHeaders/XCTest/XCActivityRecord.h +3 -3
  3. package/PrivateHeaders/XCTest/XCApplicationQuery.h +3 -3
  4. package/PrivateHeaders/XCTest/XCTElementSetTransformer-Protocol.h +2 -2
  5. package/PrivateHeaders/XCTest/XCTRunnerDaemonSession.h +1 -1
  6. package/PrivateHeaders/XCTest/XCTestManager_IDEInterface-Protocol.h +5 -5
  7. package/PrivateHeaders/XCTest/XCTestManager_ManagerInterface-Protocol.h +8 -8
  8. package/PrivateHeaders/XCTest/XCUIApplication.h +2 -2
  9. package/PrivateHeaders/XCTest/XCUIApplicationImpl.h +2 -2
  10. package/PrivateHeaders/XCTest/XCUIApplicationProcess.h +3 -5
  11. package/PrivateHeaders/XCTest/XCUIElement.h +3 -3
  12. package/PrivateHeaders/XCTest/XCUIElementQuery.h +4 -4
  13. package/PrivateHeaders/XCTest/XCUIRecorderNodeFinder.h +3 -3
  14. package/PrivateHeaders/XCTest/XCUIRecorderUtilities.h +3 -3
  15. package/Scripts/build.sh +3 -6
  16. package/WebDriverAgent.xcodeproj/project.pbxproj +66 -70
  17. package/WebDriverAgentLib/Categories/{XCElementSnapshot+FBHelpers.h → FBXCElementSnapshotWrapper+Helpers.h} +18 -11
  18. package/WebDriverAgentLib/Categories/{XCElementSnapshot+FBHelpers.m → FBXCElementSnapshotWrapper+Helpers.m} +57 -39
  19. package/WebDriverAgentLib/Categories/NSExpression+FBFormat.m +8 -3
  20. package/WebDriverAgentLib/Categories/XCUIApplication+FBAlert.m +8 -7
  21. package/WebDriverAgentLib/Categories/XCUIApplication+FBHelpers.h +2 -2
  22. package/WebDriverAgentLib/Categories/XCUIApplication+FBHelpers.m +29 -28
  23. package/WebDriverAgentLib/Categories/XCUIApplicationProcess+FBQuiescence.m +5 -0
  24. package/WebDriverAgentLib/Categories/XCUICoordinate+FBFix.m +0 -1
  25. package/WebDriverAgentLib/Categories/XCUIDevice+FBHelpers.m +8 -5
  26. package/WebDriverAgentLib/Categories/XCUIElement+FBAccessibility.h +2 -2
  27. package/WebDriverAgentLib/Categories/XCUIElement+FBAccessibility.m +5 -4
  28. package/WebDriverAgentLib/Categories/XCUIElement+FBCaching.m +3 -2
  29. package/WebDriverAgentLib/Categories/XCUIElement+FBFind.m +22 -18
  30. package/WebDriverAgentLib/Categories/XCUIElement+FBIsVisible.h +2 -3
  31. package/WebDriverAgentLib/Categories/XCUIElement+FBIsVisible.m +28 -26
  32. package/WebDriverAgentLib/Categories/XCUIElement+FBPickerWheel.m +2 -1
  33. package/WebDriverAgentLib/Categories/XCUIElement+FBResolve.m +8 -4
  34. package/WebDriverAgentLib/Categories/XCUIElement+FBScrolling.m +73 -51
  35. package/WebDriverAgentLib/Categories/XCUIElement+FBTyping.m +11 -10
  36. package/WebDriverAgentLib/Categories/XCUIElement+FBUID.h +10 -5
  37. package/WebDriverAgentLib/Categories/XCUIElement+FBUID.m +15 -3
  38. package/WebDriverAgentLib/Categories/XCUIElement+FBUtilities.h +7 -7
  39. package/WebDriverAgentLib/Categories/XCUIElement+FBUtilities.m +29 -20
  40. package/WebDriverAgentLib/Categories/XCUIElement+FBWebDriverAttributes.h +2 -2
  41. package/WebDriverAgentLib/Categories/XCUIElement+FBWebDriverAttributes.m +17 -14
  42. package/WebDriverAgentLib/Categories/XCUIElementQuery+FBHelpers.h +2 -3
  43. package/WebDriverAgentLib/Categories/XCUIElementQuery+FBHelpers.m +3 -3
  44. package/WebDriverAgentLib/Commands/FBElementCommands.m +17 -15
  45. package/WebDriverAgentLib/Commands/FBFindElementCommands.m +5 -6
  46. package/WebDriverAgentLib/FBAlert.m +16 -13
  47. package/WebDriverAgentLib/FBApplication.m +8 -8
  48. package/WebDriverAgentLib/Routing/FBElementUtils.h +11 -2
  49. package/WebDriverAgentLib/Routing/FBElementUtils.m +15 -12
  50. package/WebDriverAgentLib/Routing/FBResponsePayload.m +11 -10
  51. package/WebDriverAgentLib/Routing/FBSession.m +1 -1
  52. package/{PrivateHeaders/XCTest/XCAccessibilityElement.h → WebDriverAgentLib/Routing/FBXCAccessibilityElement.h} +19 -18
  53. package/WebDriverAgentLib/{Categories/XCAccessibilityElement+FBComparison.m → Routing/FBXCAccessibilityElement.m} +5 -11
  54. package/WebDriverAgentLib/Routing/FBXCDeviceEvent.h +35 -0
  55. package/WebDriverAgentLib/Routing/FBXCDeviceEvent.m +43 -0
  56. package/{PrivateHeaders/XCTest/XCElementSnapshot.h → WebDriverAgentLib/Routing/FBXCElementSnapshot.h} +25 -44
  57. package/WebDriverAgentLib/Routing/FBXCElementSnapshot.m +10 -0
  58. package/WebDriverAgentLib/Routing/FBXCElementSnapshotWrapper.h +30 -0
  59. package/WebDriverAgentLib/Routing/FBXCElementSnapshotWrapper.m +45 -0
  60. package/WebDriverAgentLib/Utilities/FBActiveAppDetectionPoint.h +3 -4
  61. package/WebDriverAgentLib/Utilities/FBActiveAppDetectionPoint.m +4 -4
  62. package/WebDriverAgentLib/Utilities/FBBaseActionsSynthesizer.h +2 -2
  63. package/WebDriverAgentLib/Utilities/FBBaseActionsSynthesizer.m +7 -8
  64. package/WebDriverAgentLib/Utilities/FBClassChainQueryParser.m +1 -2
  65. package/WebDriverAgentLib/Utilities/FBConfiguration.m +0 -1
  66. package/WebDriverAgentLib/Utilities/FBImageIOScaler.m +3 -0
  67. package/WebDriverAgentLib/Utilities/FBKeyboard.m +1 -2
  68. package/WebDriverAgentLib/Utilities/FBPasteboard.m +91 -3
  69. package/WebDriverAgentLib/Utilities/FBTVNavigationTracker.m +1 -1
  70. package/WebDriverAgentLib/Utilities/FBW3CActionsSynthesizer.m +3 -3
  71. package/WebDriverAgentLib/Utilities/FBXCAXClientProxy.h +10 -9
  72. package/WebDriverAgentLib/Utilities/FBXCAXClientProxy.m +14 -8
  73. package/WebDriverAgentLib/Utilities/FBXCTestDaemonsProxy.h +0 -1
  74. package/WebDriverAgentLib/Utilities/FBXCTestDaemonsProxy.m +6 -0
  75. package/WebDriverAgentLib/Utilities/FBXCodeCompatibility.h +0 -10
  76. package/WebDriverAgentLib/Utilities/FBXCodeCompatibility.m +0 -24
  77. package/WebDriverAgentLib/Utilities/FBXPath-Private.h +1 -1
  78. package/WebDriverAgentLib/Utilities/FBXPath.h +3 -3
  79. package/WebDriverAgentLib/Utilities/FBXPath.m +15 -13
  80. package/WebDriverAgentLib/Utilities/NSPredicate+FBFormat.h +14 -1
  81. package/WebDriverAgentLib/Utilities/NSPredicate+FBFormat.m +18 -9
  82. package/WebDriverAgentLib/Utilities/XCTestPrivateSymbols.m +9 -3
  83. package/WebDriverAgentLib/Utilities/XCUIApplicationProcessDelay.m +7 -1
  84. package/WebDriverAgentLib/Vendor/CocoaAsyncSocket/GCDAsyncSocket.m +7 -1
  85. package/WebDriverAgentLib/WebDriverAgentLib.h +0 -1
  86. package/WebDriverAgentRunner-Runner.app.zip +0 -0
  87. package/WebDriverAgentTests/IntegrationTests/FBPasteboardTests.m +1 -5
  88. package/WebDriverAgentTests/IntegrationTests/FBXPathIntegrationTests.m +26 -19
  89. package/WebDriverAgentTests/IntegrationTests/XCElementSnapshotHelperTests.m +24 -29
  90. package/WebDriverAgentTests/IntegrationTests/XCElementSnapshotHitPointTests.m +2 -2
  91. package/WebDriverAgentTests/IntegrationTests/XCUIElementFBFindTests.m +5 -3
  92. package/WebDriverAgentTests/IntegrationTests/XCUIElementHelperIntegrationTests.m +2 -1
  93. package/{WebDriverAgentLib/Categories/XCElementSnapshot+FBHitPoint.h → WebDriverAgentTests/UnitTests/Doubles/XCElementSnapshotDouble.h} +3 -14
  94. package/WebDriverAgentTests/UnitTests/Doubles/XCElementSnapshotDouble.m +99 -0
  95. package/WebDriverAgentTests/UnitTests/FBXPathTests.m +21 -13
  96. package/WebDriverAgentTests/UnitTests/NSPredicateFBFormatTests.m +4 -5
  97. package/package.json +1 -1
  98. package/WebDriverAgentLib/Categories/XCAccessibilityElement+FBComparison.h +0 -27
  99. package/WebDriverAgentLib/Categories/XCElementSnapshot+FBHitPoint.m +0 -29
  100. package/WebDriverAgentLib/Utilities/FBPredicate.h +0 -28
  101. package/WebDriverAgentLib/Utilities/FBPredicate.m +0 -29
@@ -13,8 +13,8 @@
13
13
  #import "FBConfiguration.h"
14
14
  #import "FBErrorBuilder.h"
15
15
  #import "FBLogger.h"
16
+ #import "FBXCElementSnapshotWrapper+Helpers.h"
16
17
  #import "FBXCodeCompatibility.h"
17
- #import "XCElementSnapshot+FBHelpers.h"
18
18
  #import "XCUIApplication+FBAlert.h"
19
19
  #import "XCUIElement+FBClassChain.h"
20
20
  #import "XCUIElement+FBTap.h"
@@ -65,13 +65,14 @@
65
65
  buildError:error];
66
66
  }
67
67
 
68
- + (BOOL)isSafariWebAlertWithSnapshot:(XCElementSnapshot *)snapshot
68
+ + (BOOL)isSafariWebAlertWithSnapshot:(id<FBXCElementSnapshot>)snapshot
69
69
  {
70
70
  if (snapshot.elementType != XCUIElementTypeOther) {
71
71
  return NO;
72
72
  }
73
73
 
74
- XCElementSnapshot *application = [snapshot fb_parentMatchingType:XCUIElementTypeApplication];
74
+ FBXCElementSnapshotWrapper *snapshotWrapper = [FBXCElementSnapshotWrapper ensureWrapped:snapshot];
75
+ id<FBXCElementSnapshot> application = [snapshotWrapper fb_parentMatchingType:XCUIElementTypeApplication];
75
76
  return nil != application && [application.label isEqualToString:FB_SAFARI_APP_NAME];
76
77
  }
77
78
 
@@ -82,22 +83,24 @@
82
83
  }
83
84
 
84
85
  NSMutableArray<NSString *> *resultText = [NSMutableArray array];
85
- XCElementSnapshot *snapshot = self.alertElement.lastSnapshot;
86
+ id<FBXCElementSnapshot> snapshot = self.alertElement.lastSnapshot;
86
87
  BOOL isSafariAlert = [self.class isSafariWebAlertWithSnapshot:snapshot];
87
- [snapshot enumerateDescendantsUsingBlock:^(XCElementSnapshot *descendant) {
88
+ [snapshot enumerateDescendantsUsingBlock:^(id<FBXCElementSnapshot> descendant) {
88
89
  XCUIElementType elementType = descendant.elementType;
89
90
  if (!(elementType == XCUIElementTypeTextView || elementType == XCUIElementTypeStaticText)) {
90
91
  return;
91
92
  }
92
-
93
+
94
+ FBXCElementSnapshotWrapper *descendantWrapper = [FBXCElementSnapshotWrapper ensureWrapped:descendant];
93
95
  if (elementType == XCUIElementTypeStaticText
94
- && nil != [descendant fb_parentMatchingType:XCUIElementTypeButton]) {
96
+ && nil != [descendantWrapper fb_parentMatchingType:XCUIElementTypeButton]) {
95
97
  return;
96
98
  }
97
99
 
98
- NSString *text = descendant.wdLabel ?: descendant.wdValue;
100
+ NSString *text = descendantWrapper.wdLabel ?: descendantWrapper.wdValue;
99
101
  if (isSafariAlert && nil != descendant.parent) {
100
- NSString *parentText = descendant.parent.wdLabel ?: descendant.parent.wdValue;
102
+ FBXCElementSnapshotWrapper *descendantParentWrapper = [FBXCElementSnapshotWrapper ensureWrapped:descendant.parent];
103
+ NSString *parentText = descendantParentWrapper.wdLabel ?: descendantParentWrapper.wdValue;
101
104
  if ([parentText isEqualToString:text]) {
102
105
  // Avoid duplicated texts on Safari alerts
103
106
  return;
@@ -143,11 +146,11 @@
143
146
  }
144
147
 
145
148
  NSMutableArray<NSString *> *labels = [NSMutableArray array];
146
- [self.alertElement.lastSnapshot enumerateDescendantsUsingBlock:^(XCElementSnapshot *descendant) {
149
+ [self.alertElement.lastSnapshot enumerateDescendantsUsingBlock:^(id<FBXCElementSnapshot> descendant) {
147
150
  if (descendant.elementType != XCUIElementTypeButton) {
148
151
  return;
149
152
  }
150
- NSString *label = descendant.wdLabel;
153
+ NSString *label = [FBXCElementSnapshotWrapper ensureWrapped:descendant].wdLabel;
151
154
  if (nil != label) {
152
155
  [labels addObject:[NSString stringWithFormat:@"%@", label]];
153
156
  }
@@ -161,7 +164,7 @@
161
164
  return [self notPresentWithError:error];
162
165
  }
163
166
 
164
- XCElementSnapshot *alertSnapshot = self.alertElement.lastSnapshot;
167
+ id<FBXCElementSnapshot> alertSnapshot = self.alertElement.lastSnapshot;
165
168
  XCUIElement *acceptButton = nil;
166
169
  if (FBConfiguration.acceptAlertButtonSelector.length) {
167
170
  NSString *errorReason = nil;
@@ -200,7 +203,7 @@
200
203
  return [self notPresentWithError:error];
201
204
  }
202
205
 
203
- XCElementSnapshot *alertSnapshot = self.alertElement.lastSnapshot;
206
+ id<FBXCElementSnapshot> alertSnapshot = self.alertElement.lastSnapshot;
204
207
  XCUIElement *dismissButton = nil;
205
208
  if (FBConfiguration.dismissAlertButtonSelector.length) {
206
209
  NSString *errorReason = nil;
@@ -9,13 +9,13 @@
9
9
 
10
10
  #import "FBApplication.h"
11
11
 
12
+ #import "FBXCAccessibilityElement.h"
12
13
  #import "FBLogger.h"
13
14
  #import "FBRunLoopSpinner.h"
14
15
  #import "FBMacros.h"
15
16
  #import "FBActiveAppDetectionPoint.h"
16
17
  #import "FBXCodeCompatibility.h"
17
18
  #import "FBXCTestDaemonsProxy.h"
18
- #import "XCAccessibilityElement.h"
19
19
  #import "XCUIApplication.h"
20
20
  #import "XCUIApplication+FBHelpers.h"
21
21
  #import "XCUIApplicationImpl.h"
@@ -39,10 +39,10 @@ static const NSTimeInterval APP_STATE_CHANGE_TIMEOUT = 5.0;
39
39
 
40
40
  + (NSArray<FBApplication *> *)fb_activeApplications
41
41
  {
42
- NSArray<XCAccessibilityElement *> *activeApplicationElements = [FBXCAXClientProxy.sharedClient activeApplications];
42
+ NSArray<id<FBXCAccessibilityElement>> *activeApplicationElements = [FBXCAXClientProxy.sharedClient activeApplications];
43
43
  NSMutableArray<FBApplication *> *result = [NSMutableArray array];
44
44
  if (activeApplicationElements.count > 0) {
45
- for (XCAccessibilityElement *applicationElement in activeApplicationElements) {
45
+ for (id<FBXCAccessibilityElement> applicationElement in activeApplicationElements) {
46
46
  FBApplication *app = [FBApplication fb_applicationWithPID:applicationElement.processIdentifier];
47
47
  if (nil != app) {
48
48
  [result addObject:app];
@@ -54,9 +54,9 @@ static const NSTimeInterval APP_STATE_CHANGE_TIMEOUT = 5.0;
54
54
 
55
55
  + (instancetype)fb_activeApplicationWithDefaultBundleId:(nullable NSString *)bundleId
56
56
  {
57
- NSArray<XCAccessibilityElement *> *activeApplicationElements = [FBXCAXClientProxy.sharedClient activeApplications];
58
- XCAccessibilityElement *activeApplicationElement = nil;
59
- XCAccessibilityElement *currentElement = nil;
57
+ NSArray<id<FBXCAccessibilityElement>> *activeApplicationElements = [FBXCAXClientProxy.sharedClient activeApplications];
58
+ id<FBXCAccessibilityElement> activeApplicationElement = nil;
59
+ id<FBXCAccessibilityElement> currentElement = nil;
60
60
  if (nil != bundleId) {
61
61
  currentElement = FBActiveAppDetectionPoint.sharedInstance.axElement;
62
62
  if (nil != currentElement) {
@@ -95,7 +95,7 @@ static const NSTimeInterval APP_STATE_CHANGE_TIMEOUT = 5.0;
95
95
  [FBLogger log:@"Consider changing the 'defaultActiveApplication' setting to the bundle identifier of the desired application under test"];
96
96
  }
97
97
  } else {
98
- for (XCAccessibilityElement *appElement in activeApplicationElements) {
98
+ for (id<FBXCAccessibilityElement> appElement in activeApplicationElements) {
99
99
  if (appElement.processIdentifier == currentElement.processIdentifier) {
100
100
  activeApplicationElement = appElement;
101
101
  break;
@@ -115,7 +115,7 @@ static const NSTimeInterval APP_STATE_CHANGE_TIMEOUT = 5.0;
115
115
 
116
116
  if (activeApplicationElements.count > 0) {
117
117
  [FBLogger logFmt:@"Getting the most recent active application (out of %@ total items)", @(activeApplicationElements.count)];
118
- for (XCAccessibilityElement *appElement in activeApplicationElements) {
118
+ for (id<FBXCAccessibilityElement> appElement in activeApplicationElements) {
119
119
  FBApplication *application = [FBApplication fb_applicationWithPID:appElement.processIdentifier];
120
120
  if (nil != application) {
121
121
  return application;
@@ -9,7 +9,8 @@
9
9
 
10
10
  #import <Foundation/Foundation.h>
11
11
  #import <WebDriverAgentLib/FBElement.h>
12
- #import "XCAccessibilityElement.h"
12
+
13
+ @protocol FBXCAccessibilityElement;
13
14
 
14
15
  NS_ASSUME_NONNULL_BEGIN
15
16
 
@@ -47,13 +48,21 @@ extern NSString *const FBUnknownAttributeException;
47
48
  */
48
49
  + (NSDictionary<NSString *, NSString *> *)wdAttributeNamesMapping;
49
50
 
51
+ /**
52
+ Gets the unique identifier of the particular XCAccessibilityElement instance in form of UUIDv4.
53
+
54
+ @param element accessiblity element instance
55
+ @return the unique element identifier or nil if it cannot be retrieved
56
+ */
57
+ + (nullable NSString *)uidWithAccessibilityElement:(id<FBXCAccessibilityElement>)element;
58
+
50
59
  /**
51
60
  Gets the unique identifier of the particular XCAccessibilityElement instance.
52
61
 
53
62
  @param element accessiblity element instance
54
63
  @return the unique element identifier or nil if it cannot be retrieved
55
64
  */
56
- + (nullable NSString *)uidWithAccessibilityElement:(XCAccessibilityElement *)element;
65
+ + (unsigned long long)idWithAccessibilityElement:(id<FBXCAccessibilityElement>)element;
57
66
 
58
67
  @end
59
68
 
@@ -9,6 +9,7 @@
9
9
 
10
10
  #import <objc/runtime.h>
11
11
 
12
+ #import "FBXCAccessibilityElement.h"
12
13
  #import "FBElementUtils.h"
13
14
  #import "FBElementTypeTransformer.h"
14
15
 
@@ -109,19 +110,9 @@ static NSString *const OBJC_PROP_ATTRIBS_SEPARATOR = @",";
109
110
  return attributeNamesMapping.copy;
110
111
  }
111
112
 
112
- static BOOL FBShouldUsePayloadForUIDExtraction = YES;
113
- static dispatch_once_t oncePayloadToken;
114
- + (NSString *)uidWithAccessibilityElement:(XCAccessibilityElement *)element
113
+ + (NSString *)uidWithAccessibilityElement:(id<FBXCAccessibilityElement>)element
115
114
  {
116
- dispatch_once(&oncePayloadToken, ^{
117
- FBShouldUsePayloadForUIDExtraction = [element respondsToSelector:@selector(payload)];
118
- });
119
- unsigned long long elementId;
120
- if (FBShouldUsePayloadForUIDExtraction) {
121
- elementId = [[element.payload objectForKey:@"uid.elementID"] longLongValue];
122
- } else {
123
- elementId = [[element valueForKey:@"_elementID"] longLongValue];
124
- }
115
+ unsigned long long elementId = [self.class idWithAccessibilityElement:element];
125
116
  int processId = element.processIdentifier;
126
117
  if (elementId < 1 || processId < 1) {
127
118
  return nil;
@@ -133,4 +124,16 @@ static dispatch_once_t oncePayloadToken;
133
124
  return uuidValue.UUIDString;
134
125
  }
135
126
 
127
+ static BOOL FBShouldUsePayloadForUIDExtraction = YES;
128
+ static dispatch_once_t oncePayloadToken;
129
+ + (unsigned long long)idWithAccessibilityElement:(id<FBXCAccessibilityElement>)element
130
+ {
131
+ dispatch_once(&oncePayloadToken, ^{
132
+ FBShouldUsePayloadForUIDExtraction = [(NSObject *)element respondsToSelector:@selector(payload)];
133
+ });
134
+ return FBShouldUsePayloadForUIDExtraction
135
+ ? [[element.payload objectForKey:@"uid.elementID"] longLongValue]
136
+ : [[(NSObject *)element valueForKey:@"_elementID"] longLongValue];
137
+ }
138
+
136
139
  @end
@@ -90,35 +90,36 @@ id<FBResponsePayload> FBResponseWithStatus(FBCommandStatus *status)
90
90
 
91
91
  inline NSDictionary *FBDictionaryResponseWithElement(XCUIElement *element, BOOL compact)
92
92
  {
93
- XCElementSnapshot *snapshot = nil;
93
+ id<FBXCElementSnapshot> snapshot = nil;
94
94
  if (nil != element.query.rootElementSnapshot) {
95
95
  snapshot = element.fb_cachedSnapshot;
96
96
  }
97
97
  if (nil == snapshot) {
98
98
  snapshot = element.lastSnapshot ?: element.fb_takeSnapshot;
99
99
  }
100
- NSMutableDictionary *dictionary = FBInsertElement(@{}, (NSString *)snapshot.wdUID).mutableCopy;
100
+ FBXCElementSnapshotWrapper *wrappedSnapshot = [FBXCElementSnapshotWrapper ensureWrapped:snapshot];
101
+ NSMutableDictionary *dictionary = FBInsertElement(@{}, (NSString *)wrappedSnapshot.wdUID).mutableCopy;
101
102
  if (!compact) {
102
103
  NSArray *fields = [FBConfiguration.elementResponseAttributes componentsSeparatedByString:@","];
103
104
  for (NSString *field in fields) {
104
105
  // 'name' here is the w3c-approved identifier for what we mean by 'type'
105
106
  if ([field isEqualToString:@"name"] || [field isEqualToString:@"type"]) {
106
- dictionary[field] = snapshot.wdType;
107
+ dictionary[field] = wrappedSnapshot.wdType;
107
108
  } else if ([field isEqualToString:@"text"]) {
108
- dictionary[field] = FBFirstNonEmptyValue(snapshot.wdValue, snapshot.wdLabel) ?: [NSNull null];
109
+ dictionary[field] = FBFirstNonEmptyValue(wrappedSnapshot.wdValue, wrappedSnapshot.wdLabel) ?: [NSNull null];
109
110
  } else if ([field isEqualToString:@"rect"]) {
110
- dictionary[field] = snapshot.wdRect;
111
+ dictionary[field] = wrappedSnapshot.wdRect;
111
112
  } else if ([field isEqualToString:@"enabled"]) {
112
- dictionary[field] = @(snapshot.wdEnabled);
113
+ dictionary[field] = @(wrappedSnapshot.wdEnabled);
113
114
  } else if ([field isEqualToString:@"displayed"]) {
114
- dictionary[field] = @(snapshot.wdVisible);
115
+ dictionary[field] = @(wrappedSnapshot.wdVisible);
115
116
  } else if ([field isEqualToString:@"selected"]) {
116
- dictionary[field] = @(snapshot.wdSelected);
117
+ dictionary[field] = @(wrappedSnapshot.wdSelected);
117
118
  } else if ([field isEqualToString:@"label"]) {
118
- dictionary[field] = snapshot.wdLabel ?: [NSNull null];
119
+ dictionary[field] = wrappedSnapshot.wdLabel ?: [NSNull null];
119
120
  } else if ([field hasPrefix:arbitraryAttrPrefix]) {
120
121
  NSString *attributeName = [field substringFromIndex:[arbitraryAttrPrefix length]];
121
- dictionary[field] = [snapshot fb_valueForWDAttributeName:attributeName] ?: [NSNull null];
122
+ dictionary[field] = [wrappedSnapshot fb_valueForWDAttributeName:attributeName] ?: [NSNull null];
122
123
  }
123
124
  }
124
125
  }
@@ -12,6 +12,7 @@
12
12
 
13
13
  #import <objc/runtime.h>
14
14
 
15
+ #import "FBXCAccessibilityElement.h"
15
16
  #import "FBAlertsMonitor.h"
16
17
  #import "FBApplication.h"
17
18
  #import "FBConfiguration.h"
@@ -19,7 +20,6 @@
19
20
  #import "FBExceptions.h"
20
21
  #import "FBMacros.h"
21
22
  #import "FBXCodeCompatibility.h"
22
- #import "XCAccessibilityElement.h"
23
23
  #import "XCUIApplication+FBQuiescence.h"
24
24
  #import "XCUIElement.h"
25
25
 
@@ -1,21 +1,18 @@
1
- //
2
- // Generated by class-dump 3.5 (64 bit).
3
- //
4
- // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard.
5
- //
6
-
7
- // FIXME: Probably we can remove here. instead, probably we should follow only XCElementSnapshot
8
-
9
- @class NSString;
10
-
11
- @interface XCAccessibilityElement : NSObject <NSCopying, NSSecureCoding>
12
- {
13
- NSString *_context;
14
- id _payload;
15
- int _processIdentifier;
16
- struct __AXUIElement *_axElement;
17
- unsigned long long _elementType;
18
- }
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
+ NS_ASSUME_NONNULL_BEGIN
13
+
14
+ @protocol FBXCAccessibilityElement <NSObject>
15
+
19
16
  @property(readonly) id payload; // @synthesize payload=_payload;
20
17
  @property(readonly) int processIdentifier; // @synthesize processIdentifier=_processIdentifier;
21
18
  @property(readonly) const struct __AXUIElement *AXUIElement; // @synthesize AXUIElement=_axElement;
@@ -32,3 +29,7 @@
32
29
  - (id)init;
33
30
 
34
31
  @end
32
+
33
+ BOOL FBIsAXElementEqualToOther(id<FBXCAccessibilityElement> first, id<FBXCAccessibilityElement> second);
34
+
35
+ NS_ASSUME_NONNULL_END
@@ -7,18 +7,12 @@
7
7
  * of patent rights can be found in the PATENTS file in the same directory.
8
8
  */
9
9
 
10
- #import "XCAccessibilityElement+FBComparison.h"
11
- #import "FBElementUtils.h"
10
+ #import "FBXCAccessibilityElement.h"
12
11
 
13
- @implementation XCAccessibilityElement (FBComparison)
12
+ #import "FBElementUtils.h"
14
13
 
15
- - (BOOL)fb_isEqualToElement:(XCAccessibilityElement *)other
14
+ BOOL FBIsAXElementEqualToOther(id<FBXCAccessibilityElement> first, id<FBXCAccessibilityElement> second)
16
15
  {
17
- if (nil == other) {
18
- return NO;
19
- }
20
- return [[FBElementUtils uidWithAccessibilityElement:self]
21
- isEqualToString:([FBElementUtils uidWithAccessibilityElement:other] ?: @"")];
16
+ return nil != second && [[FBElementUtils uidWithAccessibilityElement:first]
17
+ isEqualToString:([FBElementUtils uidWithAccessibilityElement:second] ?: @"")];
22
18
  }
23
-
24
- @end
@@ -0,0 +1,35 @@
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
+ NS_ASSUME_NONNULL_BEGIN
13
+
14
+ @protocol FBXCDeviceEvent
15
+
16
+ @property unsigned long long type; // @synthesize type=_type;
17
+ @property double rotation; // @synthesize rotation=_rotation;
18
+ @property double duration; // @synthesize duration=_duration;
19
+ @property unsigned int usage; // @synthesize usage=_usage;
20
+ @property unsigned int eventPage; // @synthesize eventPage=_eventPage;
21
+ @property(readonly) BOOL isButtonHoldEvent;
22
+
23
+ + (id)deviceEventForDigitalCrownRotation:(double)arg1 velocity:(double)arg2;
24
+ + (id)deviceEventWithPage:(unsigned int)arg1 usage:(unsigned int)arg2 duration:(double)arg3;
25
+
26
+ - (void)dispatch;
27
+
28
+ @end
29
+
30
+ _Nullable id<FBXCDeviceEvent> FBCreateXCDeviceEvent(unsigned int page,
31
+ unsigned int usage,
32
+ double duration,
33
+ NSError **error);
34
+
35
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,43 @@
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 "FBXCDeviceEvent.h"
11
+
12
+ #import "FBErrorBuilder.h"
13
+
14
+ id<FBXCDeviceEvent> FBCreateXCDeviceEvent(unsigned int page,
15
+ unsigned int usage,
16
+ double duration,
17
+ NSError **error)
18
+ {
19
+ Class xcDeviceEventClass = NSClassFromString(@"XCDeviceEvent");
20
+ if (nil == xcDeviceEventClass) {
21
+ [[[FBErrorBuilder builder]
22
+ withDescription:@"Cannot find XCDeviceEvent class"]
23
+ buildError:error];
24
+ return nil;
25
+ }
26
+ SEL deviceEventFactorySelector = NSSelectorFromString(@"deviceEventWithPage:usage:duration:");
27
+ if (![xcDeviceEventClass respondsToSelector:deviceEventFactorySelector]) {
28
+ [[[FBErrorBuilder builder]
29
+ withDescription:@"'deviceEventWithPage:usage:duration:' factory method is not found on XCDeviceEvent class"]
30
+ buildError:error];
31
+ return nil;
32
+ }
33
+ NSMethodSignature *deviceEventFactorySignature = [xcDeviceEventClass methodSignatureForSelector:deviceEventFactorySelector];
34
+ NSInvocation *deviceEventFactoryInvocation = [NSInvocation invocationWithMethodSignature:deviceEventFactorySignature];
35
+ [deviceEventFactoryInvocation setSelector:deviceEventFactorySelector];
36
+ [deviceEventFactoryInvocation setArgument:&page atIndex:2];
37
+ [deviceEventFactoryInvocation setArgument:&usage atIndex:3];
38
+ [deviceEventFactoryInvocation setArgument:&duration atIndex:4];
39
+ [deviceEventFactoryInvocation invokeWithTarget:xcDeviceEventClass];
40
+ id<FBXCDeviceEvent> __unsafe_unretained instance;
41
+ [deviceEventFactoryInvocation getReturnValue:&instance];
42
+ return instance;
43
+ }
@@ -1,41 +1,21 @@
1
- //
2
- // Generated by class-dump 3.5 (64 bit).
3
- //
4
- // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard.
5
- //
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
+ */
6
9
 
10
+ #import <XCTest/XCTest.h>
7
11
  #import <WebDriverAgentLib/CDStructures.h>
8
12
 
9
- #import <XCTest/XCUIElementAttributes.h>
13
+ @protocol FBXCAccessibilityElement;
10
14
 
11
- @class NSArray, NSDictionary, NSString, NSArray, XCAccessibilityElement, XCUIApplication;
15
+ NS_ASSUME_NONNULL_BEGIN
16
+
17
+ @protocol FBXCElementSnapshot <NSObject, XCUIElementAttributes>
12
18
 
13
- @interface XCElementSnapshot : NSObject <XCUIElementAttributes, NSSecureCoding>
14
- {
15
- NSString *_identifier;
16
- id _value;
17
- NSString *_placeholderValue;
18
- BOOL _enabled;
19
- BOOL _selected;
20
- BOOL _isMainWindow;
21
- BOOL _hasKeyboardFocus;
22
- BOOL _hasFocus;
23
- XCUIApplication *_application;
24
- unsigned long long _generation;
25
- NSString *_title;
26
- NSString *_label;
27
- unsigned long long _elementType;
28
- long long _horizontalSizeClass;
29
- long long _verticalSizeClass;
30
- XCAccessibilityElement *_accessibilityElement;
31
- XCAccessibilityElement *_parentAccessibilityElement;
32
- XCElementSnapshot *_parent;
33
- NSArray *_children;
34
- unsigned long long _traits;
35
- NSArray *_userTestingAttributes;
36
- NSDictionary *_additionalAttributes;
37
- struct CGRect _frame;
38
- }
39
19
  @property BOOL hasFocus; // @synthesize hasFocus=_hasFocus;
40
20
  @property BOOL hasKeyboardFocus; // @synthesize hasKeyboardFocus=_hasKeyboardFocus;
41
21
  @property(copy) NSDictionary *additionalAttributes; // @synthesize additionalAttributes=_additionalAttributes;
@@ -43,15 +23,15 @@
43
23
  @property unsigned long long traits; // @synthesize traits=_traits;
44
24
  @property BOOL isMainWindow; // @synthesize isMainWindow=_isMainWindow;
45
25
  @property(copy) NSArray *children; // @synthesize children=_children;
46
- @property XCElementSnapshot *parent; // @synthesize parent=_parent;
47
- @property(retain) XCAccessibilityElement *parentAccessibilityElement; // @synthesize parentAccessibilityElement=_parentAccessibilityElement;
48
- @property(retain) XCAccessibilityElement *accessibilityElement; // @synthesize accessibilityElement=_accessibilityElement;
26
+ @property id<FBXCElementSnapshot> parent; // @synthesize parent=_parent;
27
+ @property(retain) id<FBXCAccessibilityElement> parentAccessibilityElement; // @synthesize parentAccessibilityElement=_parentAccessibilityElement;
28
+ @property(retain) id<FBXCAccessibilityElement> accessibilityElement; // @synthesize accessibilityElement=_accessibilityElement;
49
29
  @property(readonly) NSArray *suggestedHitpoints;
50
30
  @property(readonly) struct CGRect visibleFrame;
51
- @property(readonly) XCElementSnapshot *scrollView;
31
+ @property(readonly) id<FBXCElementSnapshot> scrollView;
52
32
  @property(readonly, copy) NSString *truncatedValueString;
53
33
  @property(readonly) long long depth;
54
- @property(readonly, copy) XCElementSnapshot *pathFromRoot;
34
+ @property(readonly, copy) id<FBXCElementSnapshot> pathFromRoot;
55
35
  @property(readonly) BOOL isTopLevelTouchBarElement;
56
36
  @property(readonly) BOOL isTouchBarElement;
57
37
  @property(readonly, copy) NSString *sparseTreeDescription;
@@ -78,11 +58,11 @@
78
58
  - (BOOL)matchesTreeWithRoot:(id)arg1;
79
59
  - (void)mergeTreeWithSnapshot:(id)arg1;
80
60
  - (id)_childMatchingElement:(id)arg1;
81
- - (NSArray<XCElementSnapshot *> *)_allDescendants;
61
+ - (NSArray<id<FBXCElementSnapshot>> *)_allDescendants;
82
62
  - (BOOL)hasDescendantMatchingFilter:(CDUnknownBlockType)arg1;
83
- - (NSArray<XCElementSnapshot *> *)descendantsByFilteringWithBlock:(BOOL(^)(XCElementSnapshot *snapshot))block;
63
+ - (NSArray<id<FBXCElementSnapshot>> *)descendantsByFilteringWithBlock:(BOOL(^)(id<FBXCElementSnapshot> snapshot))block;
84
64
  - (id)elementSnapshotMatchingAccessibilityElement:(id)arg1;
85
- - (void)enumerateDescendantsUsingBlock:(void(^)(XCElementSnapshot *snapshot))block;
65
+ - (void)enumerateDescendantsUsingBlock:(void(^)(id<FBXCElementSnapshot> snapshot))block;
86
66
  - (id)recursiveDescriptionWithIndent:(id)arg1 includeAccessibilityElement:(BOOL)arg2;
87
67
  - (id)init;
88
68
  - (struct CGPoint)hostingAndOrientationTransformedPoint:(struct CGPoint)arg1;
@@ -92,11 +72,12 @@
92
72
  // Available since Xcode 10
93
73
  - (id)hitPoint:(NSError **)error;
94
74
 
95
- // Available since Xcode 10.0-beta4 on
96
- + (id)axAttributesForElementSnapshotKeyPaths:(id)arg1;
97
75
  // Since Xcode 10.2
98
76
  + (id)axAttributesForElementSnapshotKeyPaths:(id)arg1 isMacOS:(_Bool)arg2;
99
77
  // Since Xcode 10.0
100
- + (NSArray<NSString *> *)sanitizedElementSnapshotHierarchyAttributesForAttributes:(NSArray<NSString *> *)arg1 isMacOS:(_Bool)arg2;
78
+ + (NSArray<NSString *> *)sanitizedElementSnapshotHierarchyAttributesForAttributes:(nullable NSArray<NSString *> *)arg1
79
+ isMacOS:(_Bool)arg2;
101
80
 
102
81
  @end
82
+
83
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,10 @@
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 "FBXCElementSnapshot.h"
@@ -0,0 +1,30 @@
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 "FBXCElementSnapshot.h"
11
+ #import "FBElement.h"
12
+
13
+ NS_ASSUME_NONNULL_BEGIN
14
+
15
+ @interface FBXCElementSnapshotWrapper : NSObject<FBXCElementSnapshot>
16
+
17
+ /*!Wrapped snapshot instance */
18
+ @property (nonatomic, readonly) id<FBXCElementSnapshot> snapshot;
19
+
20
+ /**
21
+ Wraps the given snapshot.. If the given snapshot is already wrapped then the result remains unchanged.
22
+
23
+ @param snapshot snapshot instance to wrap
24
+ @returns wrapper instance
25
+ */
26
+ + (nullable instancetype)ensureWrapped:(nullable id<FBXCElementSnapshot>)snapshot;
27
+
28
+ @end
29
+
30
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,45 @@
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 "FBXCElementSnapshotWrapper.h"
11
+
12
+ #import <objc/runtime.h>
13
+
14
+ #pragma clang diagnostic push
15
+ #pragma clang diagnostic ignored "-Wobjc-protocol-property-synthesis"
16
+ #pragma clang diagnostic ignored "-Wprotocol"
17
+
18
+ @implementation FBXCElementSnapshotWrapper
19
+
20
+ - (instancetype)initWithSnapshot:(id<FBXCElementSnapshot>)snapshot;
21
+ {
22
+ self->_snapshot = snapshot;
23
+ return self;
24
+ }
25
+
26
+ + (instancetype)ensureWrapped:(id<FBXCElementSnapshot>)snapshot
27
+ {
28
+ if (nil == snapshot) {
29
+ return nil;
30
+ }
31
+ return [(NSObject *)snapshot isKindOfClass:self.class]
32
+ ? (FBXCElementSnapshotWrapper *)snapshot
33
+ : [[FBXCElementSnapshotWrapper alloc] initWithSnapshot:snapshot];
34
+ }
35
+
36
+ - (id)forwardingTargetForSelector:(SEL)aSelector
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;
41
+ }
42
+
43
+ @end
44
+
45
+ #pragma clang diagnostic pop
@@ -8,8 +8,7 @@
8
8
  */
9
9
 
10
10
  #import <XCTest/XCTest.h>
11
-
12
- @class XCAccessibilityElement;
11
+ @protocol FBXCAccessibilityElement;
13
12
 
14
13
  NS_ASSUME_NONNULL_BEGIN
15
14
 
@@ -28,14 +27,14 @@ NS_ASSUME_NONNULL_BEGIN
28
27
  * @param point The screen coordinates
29
28
  * @returns The retrieved accessbility element or nil if it cannot be detected
30
29
  */
31
- + (nullable XCAccessibilityElement *)axElementWithPoint:(CGPoint)point;
30
+ + (nullable id<FBXCAccessibilityElement>)axElementWithPoint:(CGPoint)point;
32
31
 
33
32
  /**
34
33
  * Retrieves the accessbility element for the current screen point
35
34
  *
36
35
  * @returns The retrieved accessbility element or nil if it cannot be detected
37
36
  */
38
- - (nullable XCAccessibilityElement *)axElement;
37
+ - (nullable id<FBXCAccessibilityElement>)axElement;
39
38
 
40
39
  /**
41
40
  * Sets the coordinates for the current screen point