appium-webdriveragent 3.15.0 → 4.1.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.
Files changed (87) hide show
  1. package/PrivateHeaders/XCTest/XCAXClient_iOS.h +0 -7
  2. package/PrivateHeaders/XCTest/XCAccessibilityElement.h +2 -0
  3. package/PrivateHeaders/XCTest/XCElementSnapshot.h +0 -7
  4. package/PrivateHeaders/XCTest/XCPointerEventPath.h +0 -2
  5. package/PrivateHeaders/XCTest/XCTestCaseRun.h +0 -2
  6. package/PrivateHeaders/XCTest/XCTestDriver.h +0 -6
  7. package/PrivateHeaders/XCTest/XCTestManager_ManagerInterface-Protocol.h +0 -2
  8. package/PrivateHeaders/XCTest/XCUIApplication.h +0 -3
  9. package/PrivateHeaders/XCTest/XCUIDevice.h +0 -2
  10. package/PrivateHeaders/XCTest/XCUIElement.h +0 -5
  11. package/PrivateHeaders/XCTest/XCUIElementQuery.h +0 -2
  12. package/Scripts/build-webdriveragent.js +1 -1
  13. package/Scripts/fetch-prebuilt-wda.js +1 -1
  14. package/WebDriverAgent.xcodeproj/project.pbxproj +46 -33
  15. package/WebDriverAgent.xcodeproj/project.xcworkspace/xcuserdata/kazuaki.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  16. package/WebDriverAgent.xcodeproj/xcshareddata/xcschemes/IntegrationApp.xcscheme +3 -7
  17. package/WebDriverAgent.xcodeproj/xcshareddata/xcschemes/IntegrationTests_1.xcscheme +1 -1
  18. package/WebDriverAgent.xcodeproj/xcshareddata/xcschemes/IntegrationTests_2.xcscheme +1 -1
  19. package/WebDriverAgent.xcodeproj/xcshareddata/xcschemes/IntegrationTests_3.xcscheme +1 -1
  20. package/WebDriverAgent.xcodeproj/xcshareddata/xcschemes/WebDriverAgentLib.xcscheme +10 -14
  21. package/WebDriverAgent.xcodeproj/xcshareddata/xcschemes/WebDriverAgentLib_tvOS.xcscheme +10 -14
  22. package/WebDriverAgent.xcodeproj/xcshareddata/xcschemes/WebDriverAgentRunner-nodebug.xcscheme +3 -7
  23. package/WebDriverAgent.xcodeproj/xcshareddata/xcschemes/WebDriverAgentRunner.xcscheme +1 -1
  24. package/WebDriverAgent.xcodeproj/xcshareddata/xcschemes/WebDriverAgentRunner_tvOS.xcscheme +1 -1
  25. package/WebDriverAgent.xcodeproj/xcuserdata/kazuaki.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +1208 -498
  26. package/WebDriverAgentLib/Categories/XCUIApplication+FBHelpers.h +9 -15
  27. package/WebDriverAgentLib/Categories/XCUIApplication+FBHelpers.m +4 -22
  28. package/WebDriverAgentLib/Categories/XCUIApplication+FBUIInterruptions.h +23 -0
  29. package/WebDriverAgentLib/Categories/XCUIApplication+FBUIInterruptions.m +32 -0
  30. package/WebDriverAgentLib/Categories/XCUIElement+FBSwiping.h +1 -2
  31. package/WebDriverAgentLib/Categories/XCUIElement+FBSwiping.m +1 -5
  32. package/WebDriverAgentLib/Categories/XCUIElement+FBUtilities.m +1 -7
  33. package/WebDriverAgentLib/Commands/FBAlertViewCommands.m +6 -6
  34. package/WebDriverAgentLib/Commands/FBCustomCommands.m +1 -5
  35. package/WebDriverAgentLib/Commands/FBDebugCommands.m +6 -3
  36. package/WebDriverAgentLib/FBAlert.m +1 -0
  37. package/WebDriverAgentLib/FBApplication.m +1 -12
  38. package/WebDriverAgentLib/Utilities/FBConfiguration.h +5 -0
  39. package/WebDriverAgentLib/Utilities/FBConfiguration.m +6 -0
  40. package/WebDriverAgentLib/Utilities/FBFailureProofTestCase.m +7 -10
  41. package/WebDriverAgentLib/Utilities/FBReflectionUtils.h +24 -0
  42. package/WebDriverAgentLib/Utilities/FBReflectionUtils.m +32 -0
  43. package/WebDriverAgentLib/Utilities/FBScreen.m +3 -1
  44. package/WebDriverAgentLib/Utilities/FBW3CActionsSynthesizer.m +4 -16
  45. package/WebDriverAgentLib/Utilities/FBXCAXClientProxy.h +0 -2
  46. package/WebDriverAgentLib/Utilities/FBXCAXClientProxy.m +20 -60
  47. package/WebDriverAgentLib/Utilities/FBXCTestDaemonsProxy.m +4 -15
  48. package/WebDriverAgentLib/Utilities/FBXCodeCompatibility.h +0 -17
  49. package/WebDriverAgentLib/Utilities/FBXCodeCompatibility.m +1 -55
  50. package/WebDriverAgentLib/Utilities/FBXMLGenerationOptions.h +46 -0
  51. package/WebDriverAgentLib/Utilities/FBXMLGenerationOptions.m +26 -0
  52. package/WebDriverAgentLib/Utilities/FBXPath.h +4 -3
  53. package/WebDriverAgentLib/Utilities/FBXPath.m +65 -28
  54. package/WebDriverAgentRunner/UITestingUITests.m +1 -0
  55. package/WebDriverAgentRunner-Runner.app.zip +0 -0
  56. package/WebDriverAgentTests/IntegrationTests/FBAlertTests.m +6 -0
  57. package/WebDriverAgentTests/IntegrationTests/FBAppiumMultiTouchActionsIntegrationTests.m +7 -0
  58. package/WebDriverAgentTests/IntegrationTests/FBAppiumTouchActionsIntegrationTests.m +19 -0
  59. package/WebDriverAgentTests/IntegrationTests/FBElementScreenshotTests.m +4 -0
  60. package/WebDriverAgentTests/IntegrationTests/FBElementSwipingTests.m +71 -6
  61. package/WebDriverAgentTests/IntegrationTests/FBElementVisibilityTests.m +3 -1
  62. package/WebDriverAgentTests/IntegrationTests/FBForceTouchTests.m +6 -0
  63. package/WebDriverAgentTests/IntegrationTests/FBIntegrationTestCase.m +2 -1
  64. package/WebDriverAgentTests/IntegrationTests/FBKeyboardTests.m +19 -0
  65. package/WebDriverAgentTests/IntegrationTests/FBW3CTouchActionsIntegrationTests.m +15 -0
  66. package/WebDriverAgentTests/IntegrationTests/FBXPathIntegrationTests.m +16 -2
  67. package/WebDriverAgentTests/IntegrationTests/XCUIApplicationHelperTests.m +1 -1
  68. package/WebDriverAgentTests/IntegrationTests/XCUIElementFBFindTests.m +1 -1
  69. package/WebDriverAgentTests/UnitTests/FBXPathTests.m +28 -15
  70. package/build/index.js +2 -4
  71. package/build/lib/check-dependencies.js +3 -3
  72. package/build/lib/constants.js +2 -4
  73. package/build/lib/logger.js +3 -3
  74. package/build/lib/no-session-proxy.js +3 -3
  75. package/build/lib/utils.js +16 -16
  76. package/build/lib/webdriveragent.js +16 -16
  77. package/build/lib/xcodebuild.js +5 -5
  78. package/index.js +2 -2
  79. package/lib/check-dependencies.js +1 -1
  80. package/lib/constants.js +1 -2
  81. package/lib/logger.js +1 -1
  82. package/lib/no-session-proxy.js +1 -1
  83. package/lib/utils.js +1 -1
  84. package/lib/webdriveragent.js +2 -2
  85. package/lib/xcodebuild.js +1 -1
  86. package/package.json +11 -12
  87. package/WebDriverAgentLib/.DS_Store +0 -0
@@ -11,6 +11,7 @@
11
11
 
12
12
  @class XCElementSnapshot;
13
13
  @class XCAccessibilityElement;
14
+ @class FBXMLGenerationOptions;
14
15
 
15
16
  NS_ASSUME_NONNULL_BEGIN
16
17
 
@@ -25,15 +26,6 @@ NS_ASSUME_NONNULL_BEGIN
25
26
  */
26
27
  - (BOOL)fb_deactivateWithDuration:(NSTimeInterval)duration error:(NSError **)error;
27
28
 
28
- /**
29
- Resets the authorization status for a protected resource. Available since Xcode 11.4
30
-
31
- @param resourceId A valid resource id to reset the auth status for. See https://developer.apple.com/documentation/xctest/xcuiprotectedresource?language=objc
32
- @param error If there is an error, upon return contains an NSError object that describes the problem.
33
- @return YES if the operation succeeds, otherwise NO.
34
- */
35
- - (BOOL)fb_resetAuthorizationStatusForResource:(long long)resourceId error:(NSError **)error;
36
-
37
29
  /**
38
30
  Return application elements tree in form of nested dictionaries
39
31
  */
@@ -45,18 +37,20 @@ NS_ASSUME_NONNULL_BEGIN
45
37
  - (NSDictionary *)fb_accessibilityTree;
46
38
 
47
39
  /**
48
- Return application elements tree in form of xml string
40
+ Return application elements tree in a form of xml string
41
+ with default options.
42
+
43
+ @return nil if there was a failure while retriveing the page source.
49
44
  */
50
45
  - (nullable NSString *)fb_xmlRepresentation;
51
46
 
52
47
  /**
53
- Return application elements tree in form of xml string exluding the given attribute names.
48
+ Return application elements tree in a form of xml string
54
49
 
55
- @param excludedAttributes the list of XML attribute names to be excluded from the resulting document.
56
- Invalid attribute names are silently skipped
57
- @returns The XML representation of the current element as a string
50
+ @param options Optional values that affect the resulting XML generation process.
51
+ @return nil if there was a failure while retriveing the page source.
58
52
  */
59
- - (NSString *)fb_xmlRepresentationWithoutAttributes:(NSArray<NSString *> *)excludedAttributes;
53
+ - (nullable NSString *)fb_xmlRepresentationWithOptions:(nullable FBXMLGenerationOptions *)options;
60
54
 
61
55
  /**
62
56
  Return application elements tree in form of internal XCTest debugDescription string
@@ -20,6 +20,7 @@
20
20
  #import "FBXPath.h"
21
21
  #import "FBXCTestDaemonsProxy.h"
22
22
  #import "FBXCAXClientProxy.h"
23
+ #import "FBXMLGenerationOptions.h"
23
24
  #import "XCAccessibilityElement.h"
24
25
  #import "XCElementSnapshot+FBHelpers.h"
25
26
  #import "XCUIDevice+FBHelpers.h"
@@ -180,15 +181,12 @@ static NSString* const FBUnknownBundleId = @"unknown";
180
181
 
181
182
  - (NSString *)fb_xmlRepresentation
182
183
  {
183
- return [FBXPath xmlStringWithRootElement:self excludingAttributes:nil];
184
+ return [self fb_xmlRepresentationWithOptions:nil];
184
185
  }
185
186
 
186
- - (NSString *)fb_xmlRepresentationWithoutAttributes:(NSArray<NSString *> *)excludedAttributes
187
+ - (NSString *)fb_xmlRepresentationWithOptions:(FBXMLGenerationOptions *)options
187
188
  {
188
- #pragma clang diagnostic push
189
- #pragma clang diagnostic ignored "-Wnullable-to-nonnull-conversion"
190
- return [FBXPath xmlStringWithRootElement:self excludingAttributes:excludedAttributes];
191
- #pragma clang diagnostic pop
189
+ return [FBXPath xmlStringWithRootElement:self options:options];
192
190
  }
193
191
 
194
192
  - (NSString *)fb_descriptionRepresentation
@@ -219,22 +217,6 @@ static NSString* const FBUnknownBundleId = @"unknown";
219
217
  }
220
218
  #endif
221
219
 
222
- - (BOOL)fb_resetAuthorizationStatusForResource:(long long)resourceId error:(NSError **)error
223
- {
224
- SEL selector = NSSelectorFromString(@"resetAuthorizationStatusForResource:");
225
- if (![self respondsToSelector:selector]) {
226
- return [[[FBErrorBuilder builder]
227
- withDescription:@"'resetAuthorizationStatusForResource' API is only supported for Xcode SDK 11.4 and later"]
228
- buildError:error];
229
- }
230
- NSMethodSignature *signature = [self methodSignatureForSelector:selector];
231
- NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
232
- [invocation setSelector:selector];
233
- [invocation setArgument:&resourceId atIndex:2]; // 0 and 1 are reserved
234
- [invocation invokeWithTarget:self];
235
- return YES;
236
- }
237
-
238
220
  - (BOOL)fb_dismissKeyboardWithKeyNames:(nullable NSArray<NSString *> *)keyNames
239
221
  error:(NSError **)error
240
222
  {
@@ -0,0 +1,23 @@
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
+ @interface XCUIApplication (FBUIInterruptions)
15
+
16
+ /**
17
+ * Disables automatic UI interruptions handling for all applications.
18
+ */
19
+ + (void)fb_disableUIInterruptionsHandling;
20
+
21
+ @end
22
+
23
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,32 @@
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 "XCUIApplication+FBUIInterruptions.h"
11
+
12
+ #import "FBReflectionUtils.h"
13
+ #import "XCUIApplication.h"
14
+
15
+ @implementation XCUIApplication (FBUIInterruptions)
16
+
17
+ - (BOOL)fb_doesNotHandleUIInterruptions
18
+ {
19
+ return YES;
20
+ }
21
+
22
+ + (void)fb_disableUIInterruptionsHandling
23
+ {
24
+ static dispatch_once_t onceToken;
25
+ dispatch_once(&onceToken, ^{
26
+ FBReplaceMethod([self class],
27
+ @selector(doesNotHandleUIInterruptions),
28
+ @selector(fb_doesNotHandleUIInterruptions));
29
+ });
30
+ }
31
+
32
+ @end
@@ -16,8 +16,7 @@ NS_ASSUME_NONNULL_BEGIN
16
16
  * Performs swipe gesture on the element
17
17
  *
18
18
  * @param direction Swipe direction. The following values are supported: up, down, left and right
19
- * @param velocity Swipe speed in pixels per second. This parameter is only supported since Xcode 11.4
20
- * nil value means that the default velocity is going to be used.
19
+ * @param velocity Swipe speed in pixels per second
21
20
  */
22
21
  - (void)fb_swipeWithDirection:(NSString *)direction velocity:(nullable NSNumber*)velocity;
23
22
 
@@ -18,11 +18,7 @@
18
18
  {
19
19
  double velocityValue = .0;
20
20
  if (nil != velocity) {
21
- if ([self respondsToSelector:@selector(swipeUpWithVelocity:)]) {
22
- velocityValue = [velocity doubleValue];
23
- } else {
24
- [FBLogger log:@"Custom velocity values are only supported since Xcode SDK 11.4. The default velocity will be used instead"];
25
- }
21
+ velocityValue = [velocity doubleValue];
26
22
  }
27
23
 
28
24
  if (velocityValue > 0) {
@@ -45,13 +45,7 @@
45
45
  {
46
46
  NSError *error = nil;
47
47
  self.fb_isResolvedFromCache = @(NO);
48
- if (self.query.fb_isUniqueSnapshotSupported) {
49
- self.lastSnapshot = [self.fb_query fb_uniqueSnapshotWithError:&error];
50
- } else {
51
- self.lastSnapshot = nil;
52
- // TODO: Remove this branch after Xcode10 support is dropped
53
- [self fb_resolveWithError:&error];
54
- }
48
+ self.lastSnapshot = [self.fb_query fb_uniqueSnapshotWithError:&error];
55
49
  if (nil == self.lastSnapshot) {
56
50
  NSString *hintText = @"Make sure the application UI has the expected state";
57
51
  if (nil != error
@@ -38,8 +38,8 @@
38
38
 
39
39
  + (id<FBResponsePayload>)handleAlertGetTextCommand:(FBRouteRequest *)request
40
40
  {
41
- FBSession *session = request.session;
42
- NSString *alertText = [FBAlert alertWithApplication:session.activeApplication].text;
41
+ FBApplication *application = request.session.activeApplication ?: FBApplication.fb_activeApplication;
42
+ NSString *alertText = [FBAlert alertWithApplication:application].text;
43
43
  if (!alertText) {
44
44
  return FBResponseWithStatus([FBCommandStatus noAlertOpenErrorWithMessage:nil
45
45
  traceback:nil]);
@@ -73,9 +73,9 @@
73
73
 
74
74
  + (id<FBResponsePayload>)handleAlertAcceptCommand:(FBRouteRequest *)request
75
75
  {
76
- FBSession *session = request.session;
76
+ FBApplication *application = request.session.activeApplication ?: FBApplication.fb_activeApplication;
77
77
  NSString *name = request.arguments[@"name"];
78
- FBAlert *alert = [FBAlert alertWithApplication:session.activeApplication];
78
+ FBAlert *alert = [FBAlert alertWithApplication:application];
79
79
  NSError *error;
80
80
 
81
81
  if (!alert.isPresent) {
@@ -96,9 +96,9 @@
96
96
 
97
97
  + (id<FBResponsePayload>)handleAlertDismissCommand:(FBRouteRequest *)request
98
98
  {
99
- FBSession *session = request.session;
99
+ FBApplication *application = request.session.activeApplication ?: FBApplication.fb_activeApplication;
100
100
  NSString *name = request.arguments[@"name"];
101
- FBAlert *alert = [FBAlert alertWithApplication:session.activeApplication];
101
+ FBAlert *alert = [FBAlert alertWithApplication:application];
102
102
  NSError *error;
103
103
 
104
104
  if (!alert.isPresent) {
@@ -292,11 +292,7 @@
292
292
  NSString *errMsg = @"The 'resource' argument must be set to a valid resource identifier (numeric value). See https://developer.apple.com/documentation/xctest/xcuiprotectedresource?language=objc";
293
293
  return FBResponseWithStatus([FBCommandStatus invalidArgumentErrorWithMessage:errMsg traceback:nil]);
294
294
  }
295
- NSError *error;
296
- if (![request.session.activeApplication fb_resetAuthorizationStatusForResource:resource.longLongValue
297
- error:&error]) {
298
- return FBResponseWithUnknownError(error);
299
- }
295
+ [request.session.activeApplication resetAuthorizationStatusForResource:(XCUIProtectedResource)resource.longLongValue];
300
296
  return FBResponseWithOK();
301
297
  }
302
298
 
@@ -12,6 +12,7 @@
12
12
  #import "FBApplication.h"
13
13
  #import "FBRouteRequest.h"
14
14
  #import "FBSession.h"
15
+ #import "FBXMLGenerationOptions.h"
15
16
  #import "XCUIApplication+FBHelpers.h"
16
17
  #import "XCUIElement+FBUtilities.h"
17
18
  #import "FBXPath.h"
@@ -43,14 +44,16 @@ static NSString *const SOURCE_FORMAT_DESCRIPTION = @"description";
43
44
  // This method might be called without session
44
45
  FBApplication *application = request.session.activeApplication ?: FBApplication.fb_activeApplication;
45
46
  NSString *sourceType = request.parameters[@"format"] ?: SOURCE_FORMAT_XML;
47
+ NSString *sourceScope = request.parameters[@"scope"];
46
48
  id result;
47
49
  if ([sourceType caseInsensitiveCompare:SOURCE_FORMAT_XML] == NSOrderedSame) {
48
50
  NSArray<NSString *> *excludedAttributes = nil == request.parameters[@"excluded_attributes"]
49
51
  ? nil
50
52
  : [request.parameters[@"excluded_attributes"] componentsSeparatedByString:@","];
51
- result = nil == excludedAttributes
52
- ? application.fb_xmlRepresentation
53
- : [application fb_xmlRepresentationWithoutAttributes:(NSArray<NSString *> *)excludedAttributes];
53
+ result = [application fb_xmlRepresentationWithOptions:
54
+ [[[FBXMLGenerationOptions new]
55
+ withExcludedAttributes:excludedAttributes]
56
+ withScope:sourceScope]];
54
57
  } else if ([sourceType caseInsensitiveCompare:SOURCE_FORMAT_JSON] == NSOrderedSame) {
55
58
  result = application.fb_tree;
56
59
  } else if ([sourceType caseInsensitiveCompare:SOURCE_FORMAT_DESCRIPTION] == NSOrderedSame) {
@@ -226,6 +226,7 @@
226
226
  ? buttons.firstObject
227
227
  : buttons.lastObject;
228
228
  }
229
+
229
230
  return nil == dismissButton
230
231
  ? [[[FBErrorBuilder builder]
231
232
  withDescriptionFormat:@"Failed to find dismiss button for alert: %@", self.alertElement]
@@ -133,23 +133,12 @@ static const NSTimeInterval APP_STATE_CHANGE_TIMEOUT = 5.0;
133
133
  [[FBXCAXClientProxy.sharedClient systemApplication] processIdentifier]];
134
134
  }
135
135
 
136
- + (instancetype)appWithPID:(pid_t)processID
137
- {
138
- if ([NSProcessInfo processInfo].processIdentifier == processID) {
139
- return nil;
140
- }
141
- return [super appWithPID:processID];
142
- }
143
-
144
136
  + (instancetype)applicationWithPID:(pid_t)processID
145
137
  {
146
138
  if ([NSProcessInfo processInfo].processIdentifier == processID) {
147
139
  return nil;
148
140
  }
149
- if ([FBXCAXClientProxy.sharedClient hasProcessTracker]) {
150
- return (FBApplication *)[FBXCAXClientProxy.sharedClient monitoredApplicationWithProcessIdentifier:processID];
151
- }
152
- return [super applicationWithPID:processID];
141
+ return (FBApplication *)[FBXCAXClientProxy.sharedClient monitoredApplicationWithProcessIdentifier:processID];
153
142
  }
154
143
 
155
144
  - (void)launch
@@ -118,6 +118,11 @@ extern NSString *const FBSnapshotMaxDepthKey;
118
118
  */
119
119
  + (BOOL)verboseLoggingEnabled;
120
120
 
121
+ /**
122
+ Disables automatic handling of XCTest UI interruptions.
123
+ */
124
+ + (void)disableApplicationUIInterruptionsHandling;
125
+
121
126
  /**
122
127
  * Configure keyboards preference to make test running stable
123
128
  */
@@ -17,6 +17,7 @@
17
17
  #import "XCTestPrivateSymbols.h"
18
18
  #import "XCElementSnapshot.h"
19
19
  #import "XCTestConfiguration.h"
20
+ #import "XCUIApplication+FBUIInterruptions.h"
20
21
 
21
22
  static NSUInteger const DefaultStartingPort = 8100;
22
23
  static NSUInteger const DefaultMjpegServerPort = 9100;
@@ -74,6 +75,11 @@ static UIInterfaceOrientation FBScreenshotOrientation = UIInterfaceOrientationUn
74
75
  [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"XCTDisableRemoteQueryEvaluation"];
75
76
  }
76
77
 
78
+ + (void)disableApplicationUIInterruptionsHandling
79
+ {
80
+ [XCUIApplication fb_disableUIInterruptionsHandling];
81
+ }
82
+
77
83
  + (void)enableXcTestDebugLogs
78
84
  {
79
85
  ((XCTestConfiguration *)XCTestConfiguration.activeTestConfiguration).emitOSLogs = YES;
@@ -23,18 +23,15 @@
23
23
  {
24
24
  [super setUp];
25
25
  self.continueAfterFailure = YES;
26
- if ([self respondsToSelector:@selector(internalImplementation)]) {
27
- // The `internalImplementation` API has been removed since Xcode 11.4
28
- self.internalImplementation =
29
- (_XCTestCaseImplementation *)[FBXCTestCaseImplementationFailureHoldingProxy
30
- proxyWithXCTestCaseImplementation:self.internalImplementation];
31
- } else {
32
- // https://github.com/appium/appium/issues/13949
33
- self.shouldSetShouldHaltWhenReceivesControl = NO;
34
- self.shouldHaltWhenReceivesControl = NO;
35
- }
26
+ // https://github.com/appium/appium/issues/13949
27
+ self.shouldSetShouldHaltWhenReceivesControl = NO;
28
+ self.shouldHaltWhenReceivesControl = NO;
36
29
  }
37
30
 
31
+
32
+ /**
33
+ Override 'recordFailureWithDescription' to not stop by failures.
34
+ */
38
35
  - (void)recordFailureWithDescription:(NSString *)description
39
36
  inFile:(NSString *)filePath
40
37
  atLine:(NSUInteger)lineNumber
@@ -0,0 +1,24 @@
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 <Foundation/Foundation.h>
11
+
12
+ NS_ASSUME_NONNULL_BEGIN
13
+
14
+ /**
15
+ * Swizzles the implemntation of originalSelector with the swizzledSelector for the given class.
16
+ * Both methods must belong to this class.
17
+ *
18
+ * @param cls The class where to swizzle
19
+ * @param originalSelector original method selector
20
+ * @paramswizzledSelector swizzled method selector
21
+ */
22
+ void FBReplaceMethod(Class cls, SEL originalSelector, SEL swizzledSelector);
23
+
24
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,32 @@
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 "FBReflectionUtils.h"
11
+
12
+ #import <objc/runtime.h>
13
+
14
+ void FBReplaceMethod(Class class, SEL originalSelector, SEL swizzledSelector) {
15
+ Method originalMethod = class_getInstanceMethod(class, originalSelector);
16
+ Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector);
17
+
18
+ BOOL didAddMethod =
19
+ class_addMethod(class,
20
+ originalSelector,
21
+ method_getImplementation(swizzledMethod),
22
+ method_getTypeEncoding(swizzledMethod));
23
+
24
+ if (didAddMethod) {
25
+ class_replaceMethod(class,
26
+ swizzledSelector,
27
+ method_getImplementation(originalMethod),
28
+ method_getTypeEncoding(originalMethod));
29
+ } else {
30
+ method_exchangeImplementations(originalMethod, swizzledMethod);
31
+ }
32
+ }
@@ -35,7 +35,9 @@
35
35
  if (!mainStatusBar || (expectVisibleBar && !mainStatusBar.fb_isVisible)) {
36
36
  return CGSizeZero;
37
37
  }
38
- return mainStatusBar.frame.size;
38
+ CGSize result = mainStatusBar.frame.size;
39
+ // Workaround for https://github.com/appium/appium/issues/15961
40
+ return CGSizeMake(MAX(result.width, result.height), MIN(result.width, result.height));
39
41
  }
40
42
 
41
43
  @end
@@ -519,22 +519,10 @@ static NSString *const FB_KEY_ACTIONS = @"actions";
519
519
  // TODO: The current approach throws zero division error on execution
520
520
  // NSUInteger modifiers = [self collectModifersWithItems:allItems currentItemIndex:currentItemIndex];
521
521
  // [resultPath setModifiers:modifiers mergeWithCurrentModifierFlags:NO atOffset:0];
522
- if ([resultPath respondsToSelector:@selector(typeText:atOffset:typingSpeed:)]) {
523
- [resultPath typeText:text
524
- atOffset:offset
525
- typingSpeed:FBConfiguration.maxTypingFrequency];
526
- } else if ([resultPath respondsToSelector:@selector(typeText:atOffset:typingSpeed:shouldRedact:)]) {
527
- [resultPath typeText:text
528
- atOffset:offset
529
- typingSpeed:FBConfiguration.maxTypingFrequency
530
- shouldRedact:YES];
531
- } else {
532
- NSString *description = @"typeText: selector signature has been unexpectedly changed in the current XCTest SDK. Consider switching to the most recent WDA version";
533
- if (error) {
534
- *error = [[FBErrorBuilder.builder withDescription:description] build];
535
- }
536
- return nil;
537
- }
522
+ [resultPath typeText:text
523
+ atOffset:offset
524
+ typingSpeed:FBConfiguration.maxTypingFrequency
525
+ shouldRedact:YES];
538
526
  return @[resultPath];
539
527
  }
540
528
 
@@ -41,8 +41,6 @@ NS_ASSUME_NONNULL_BEGIN
41
41
  - (NSDictionary *)attributesForElement:(XCAccessibilityElement *)element
42
42
  attributes:(NSArray *)attributes;
43
43
 
44
- - (BOOL)hasProcessTracker;
45
-
46
44
  - (XCUIApplication *)monitoredApplicationWithProcessIdentifier:(int)pid;
47
45
 
48
46
  @end
@@ -13,9 +13,10 @@
13
13
 
14
14
  #import "FBConfiguration.h"
15
15
  #import "FBLogger.h"
16
+ #import "FBMacros.h"
17
+ #import "FBReflectionUtils.h"
16
18
  #import "XCAXClient_iOS.h"
17
19
  #import "XCUIDevice.h"
18
- #import "FBMacros.h"
19
20
 
20
21
  static id FBAXClient = nil;
21
22
 
@@ -35,28 +36,9 @@ static id FBAXClient = nil;
35
36
  {
36
37
  static dispatch_once_t onceToken;
37
38
  dispatch_once(&onceToken, ^{
38
- Class class = [self class];
39
-
40
- SEL originalSelector = @selector(defaultParameters);
41
- SEL swizzledSelector = @selector(fb_getParametersForElementSnapshot);
42
-
43
- Method originalMethod = class_getInstanceMethod(class, originalSelector);
44
- Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector);
45
-
46
- BOOL didAddMethod =
47
- class_addMethod(class,
48
- originalSelector,
49
- method_getImplementation(swizzledMethod),
50
- method_getTypeEncoding(swizzledMethod));
51
-
52
- if (didAddMethod) {
53
- class_replaceMethod(class,
54
- swizzledSelector,
55
- method_getImplementation(originalMethod),
56
- method_getTypeEncoding(originalMethod));
57
- } else {
58
- method_exchangeImplementations(originalMethod, swizzledMethod);
59
- }
39
+ SEL originalParametersSelector = @selector(defaultParameters);
40
+ SEL swizzledParametersSelector = @selector(fb_getParametersForElementSnapshot);
41
+ FBReplaceMethod([self class], originalParametersSelector, swizzledParametersSelector);
60
42
  });
61
43
  }
62
44
 
@@ -70,11 +52,7 @@ static id FBAXClient = nil;
70
52
  static dispatch_once_t onceToken;
71
53
  dispatch_once(&onceToken, ^{
72
54
  instance = [[self alloc] init];
73
- if ([XCAXClient_iOS.class respondsToSelector:@selector(sharedClient)]) {
74
- FBAXClient = [XCAXClient_iOS sharedClient];
75
- } else {
76
- FBAXClient = [XCUIDevice.sharedDevice accessibilityInterface];
77
- }
55
+ FBAXClient = [XCUIDevice.sharedDevice accessibilityInterface];
78
56
  });
79
57
  return instance;
80
58
  }
@@ -99,18 +77,13 @@ static id FBAXClient = nil;
99
77
  [parameters addEntriesFromDictionary:self.defaultParameters];
100
78
  parameters[FBSnapshotMaxDepthKey] = maxDepth;
101
79
  }
102
- if ([FBAXClient respondsToSelector:@selector(requestSnapshotForElement:attributes:parameters:error:)]) {
103
- id result = [FBAXClient requestSnapshotForElement:element
104
- attributes:attributes
105
- parameters:[parameters copy]
106
- error:error];
107
- XCElementSnapshot *snapshot = [result valueForKey:@"_rootElementSnapshot"];
108
- return nil == snapshot ? result : snapshot;
109
- }
110
- return [FBAXClient snapshotForElement:element
111
- attributes:attributes
112
- parameters:[parameters copy]
113
- error:error];
80
+
81
+ id result = [FBAXClient requestSnapshotForElement:element
82
+ attributes:attributes
83
+ parameters:[parameters copy]
84
+ error:error];
85
+ XCElementSnapshot *snapshot = [result valueForKey:@"_rootElementSnapshot"];
86
+ return nil == snapshot ? result : snapshot;
114
87
  }
115
88
 
116
89
  - (NSArray<XCAccessibilityElement *> *)activeApplications
@@ -137,27 +110,14 @@ static id FBAXClient = nil;
137
110
  - (NSDictionary *)attributesForElement:(XCAccessibilityElement *)element
138
111
  attributes:(NSArray *)attributes
139
112
  {
140
- if ([FBAXClient respondsToSelector:@selector(attributesForElement:attributes:error:)]) {
141
- NSError *error = nil;
142
- NSDictionary* result = [FBAXClient attributesForElement:element
143
- attributes:attributes
144
- error:&error];
145
- if (error) {
146
- [FBLogger logFmt:@"Cannot retrieve element attribute(s) %@. Original error: %@", attributes, error.description];
147
- }
148
- return result;
113
+ NSError *error = nil;
114
+ NSDictionary* result = [FBAXClient attributesForElement:element
115
+ attributes:attributes
116
+ error:&error];
117
+ if (error) {
118
+ [FBLogger logFmt:@"Cannot retrieve element attribute(s) %@. Original error: %@", attributes, error.description];
149
119
  }
150
- return [FBAXClient attributesForElement:element attributes:attributes];
151
- }
152
-
153
- - (BOOL)hasProcessTracker
154
- {
155
- static BOOL hasTracker;
156
- static dispatch_once_t onceToken;
157
- dispatch_once(&onceToken, ^{
158
- hasTracker = [FBAXClient respondsToSelector:@selector(applicationProcessTracker)];
159
- });
160
- return hasTracker;
120
+ return result;
161
121
  }
162
122
 
163
123
  - (XCUIApplication *)monitoredApplicationWithProcessIdentifier:(int)pid
@@ -50,12 +50,7 @@ static dispatch_once_t onceTestRunnerDaemonClass;
50
50
 
51
51
  + (id<XCTestManager_ManagerInterface>)retrieveTestRunnerProxy
52
52
  {
53
- if ([XCTestDriver respondsToSelector:@selector(sharedTestDriver)] &&
54
- [[XCTestDriver sharedTestDriver] respondsToSelector:@selector(managerProxy)]) {
55
- return [XCTestDriver sharedTestDriver].managerProxy;
56
- } else {
57
- return ((XCTRunnerDaemonSession *)[FBXCTRunnerDaemonSessionClass sharedSession]).daemonProxy;
58
- }
53
+ return ((XCTRunnerDaemonSession *)[FBXCTRunnerDaemonSessionClass sharedSession]).daemonProxy;
59
54
  }
60
55
 
61
56
  #if !TARGET_OS_TV
@@ -87,15 +82,9 @@ static dispatch_once_t onceTestRunnerDaemonClass;
87
82
  XCEventGeneratorHandler handlerBlock = ^(XCSynthesizedEventRecord *innerRecord, NSError *invokeError) {
88
83
  errorHandler(invokeError);
89
84
  };
90
- if ([XCUIDevice.sharedDevice respondsToSelector:@selector(eventSynthesizer)]) {
91
- [[XCUIDevice.sharedDevice eventSynthesizer] synthesizeEvent:record completion:(id)^(BOOL result, NSError *invokeError) {
92
- handlerBlock(record, invokeError);
93
- }];
94
- } else {
95
- [[FBXCTRunnerDaemonSessionClass sharedSession] synthesizeEvent:record completion:^(NSError *invokeError){
96
- handlerBlock(record, invokeError);
97
- }];
98
- }
85
+ [[XCUIDevice.sharedDevice eventSynthesizer] synthesizeEvent:record completion:(id)^(BOOL result, NSError *invokeError) {
86
+ handlerBlock(record, invokeError);
87
+ }];
99
88
  }
100
89
  }];
101
90
  return didSucceed;