appium-webdriveragent 3.16.0 → 4.1.4

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 (81) 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/README.md +6 -0
  13. package/Scripts/build-webdriveragent.js +1 -1
  14. package/Scripts/build.sh +7 -2
  15. package/Scripts/fetch-prebuilt-wda.js +1 -1
  16. package/WebDriverAgent.xcodeproj/project.pbxproj +10 -33
  17. package/WebDriverAgent.xcodeproj/xcshareddata/xcschemes/IntegrationApp.xcscheme +3 -7
  18. package/WebDriverAgent.xcodeproj/xcshareddata/xcschemes/IntegrationTests_1.xcscheme +1 -1
  19. package/WebDriverAgent.xcodeproj/xcshareddata/xcschemes/IntegrationTests_2.xcscheme +1 -1
  20. package/WebDriverAgent.xcodeproj/xcshareddata/xcschemes/IntegrationTests_3.xcscheme +1 -1
  21. package/WebDriverAgent.xcodeproj/xcshareddata/xcschemes/WebDriverAgentLib.xcscheme +10 -14
  22. package/WebDriverAgent.xcodeproj/xcshareddata/xcschemes/WebDriverAgentLib_tvOS.xcscheme +10 -14
  23. package/WebDriverAgent.xcodeproj/xcshareddata/xcschemes/WebDriverAgentRunner-nodebug.xcscheme +3 -7
  24. package/WebDriverAgent.xcodeproj/xcshareddata/xcschemes/WebDriverAgentRunner.xcscheme +1 -1
  25. package/WebDriverAgent.xcodeproj/xcshareddata/xcschemes/WebDriverAgentRunner_tvOS.xcscheme +1 -1
  26. package/WebDriverAgentLib/Categories/XCUIApplication+FBHelpers.h +0 -9
  27. package/WebDriverAgentLib/Categories/XCUIApplication+FBHelpers.m +0 -16
  28. package/WebDriverAgentLib/Categories/XCUIElement+FBSwiping.h +1 -2
  29. package/WebDriverAgentLib/Categories/XCUIElement+FBSwiping.m +1 -5
  30. package/WebDriverAgentLib/Categories/XCUIElement+FBUtilities.m +1 -7
  31. package/WebDriverAgentLib/Commands/FBAlertViewCommands.m +6 -6
  32. package/WebDriverAgentLib/Commands/FBCustomCommands.m +1 -5
  33. package/WebDriverAgentLib/FBAlert.m +1 -0
  34. package/WebDriverAgentLib/FBApplication.m +1 -12
  35. package/WebDriverAgentLib/Utilities/FBFailureProofTestCase.m +7 -10
  36. package/WebDriverAgentLib/Utilities/FBScreen.m +3 -1
  37. package/WebDriverAgentLib/Utilities/FBW3CActionsSynthesizer.m +4 -16
  38. package/WebDriverAgentLib/Utilities/FBXCAXClientProxy.h +0 -2
  39. package/WebDriverAgentLib/Utilities/FBXCAXClientProxy.m +15 -37
  40. package/WebDriverAgentLib/Utilities/FBXCTestDaemonsProxy.m +4 -15
  41. package/WebDriverAgentLib/Utilities/FBXCodeCompatibility.h +0 -17
  42. package/WebDriverAgentLib/Utilities/FBXCodeCompatibility.m +1 -55
  43. package/WebDriverAgentRunner-Runner.app.zip +0 -0
  44. package/WebDriverAgentTests/IntegrationTests/FBAlertTests.m +5 -0
  45. package/WebDriverAgentTests/IntegrationTests/FBAppiumMultiTouchActionsIntegrationTests.m +7 -0
  46. package/WebDriverAgentTests/IntegrationTests/FBAppiumTouchActionsIntegrationTests.m +19 -0
  47. package/WebDriverAgentTests/IntegrationTests/FBElementScreenshotTests.m +4 -0
  48. package/WebDriverAgentTests/IntegrationTests/FBElementSwipingTests.m +71 -6
  49. package/WebDriverAgentTests/IntegrationTests/FBElementVisibilityTests.m +3 -1
  50. package/WebDriverAgentTests/IntegrationTests/FBForceTouchTests.m +6 -0
  51. package/WebDriverAgentTests/IntegrationTests/FBIntegrationTestCase.m +2 -1
  52. package/WebDriverAgentTests/IntegrationTests/FBKeyboardTests.m +19 -0
  53. package/WebDriverAgentTests/IntegrationTests/FBW3CTouchActionsIntegrationTests.m +15 -0
  54. package/WebDriverAgentTests/IntegrationTests/XCUIApplicationHelperTests.m +1 -1
  55. package/WebDriverAgentTests/IntegrationTests/XCUIElementFBFindTests.m +1 -1
  56. package/build/index.js +6 -6
  57. package/build/lib/check-dependencies.js +4 -4
  58. package/build/lib/constants.js +2 -4
  59. package/build/lib/logger.js +3 -3
  60. package/build/lib/no-session-proxy.js +3 -3
  61. package/build/lib/utils.js +25 -25
  62. package/build/lib/webdriveragent.js +17 -17
  63. package/build/lib/xcodebuild.js +5 -5
  64. package/index.js +2 -2
  65. package/lib/check-dependencies.js +1 -1
  66. package/lib/constants.js +1 -2
  67. package/lib/logger.js +1 -1
  68. package/lib/no-session-proxy.js +1 -1
  69. package/lib/utils.js +1 -1
  70. package/lib/webdriveragent.js +2 -2
  71. package/lib/xcodebuild.js +1 -1
  72. package/package.json +13 -12
  73. package/PrivateHeaders/.DS_Store +0 -0
  74. package/WebDriverAgent.xcodeproj/project.xcworkspace/xcuserdata/elf.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  75. package/WebDriverAgent.xcodeproj/xcuserdata/elf.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +0 -91
  76. package/WebDriverAgent.xcodeproj/xcuserdata/elf.xcuserdatad/xcschemes/xcschememanagement.plist +0 -59
  77. package/WebDriverAgentLib/.DS_Store +0 -0
  78. package/WebDriverAgentLib/Utilities/LRUCache/.DS_Store +0 -0
  79. package/WebDriverAgentLib/Vendor/.DS_Store +0 -0
  80. package/WebDriverAgentRunner/.DS_Store +0 -0
  81. package/WebDriverAgentTests/IntegrationApp/Resources/.DS_Store +0 -0
@@ -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
 
@@ -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
@@ -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
@@ -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
@@ -52,11 +52,7 @@ static id FBAXClient = nil;
52
52
  static dispatch_once_t onceToken;
53
53
  dispatch_once(&onceToken, ^{
54
54
  instance = [[self alloc] init];
55
- if ([XCAXClient_iOS.class respondsToSelector:@selector(sharedClient)]) {
56
- FBAXClient = [XCAXClient_iOS sharedClient];
57
- } else {
58
- FBAXClient = [XCUIDevice.sharedDevice accessibilityInterface];
59
- }
55
+ FBAXClient = [XCUIDevice.sharedDevice accessibilityInterface];
60
56
  });
61
57
  return instance;
62
58
  }
@@ -81,18 +77,13 @@ static id FBAXClient = nil;
81
77
  [parameters addEntriesFromDictionary:self.defaultParameters];
82
78
  parameters[FBSnapshotMaxDepthKey] = maxDepth;
83
79
  }
84
- if ([FBAXClient respondsToSelector:@selector(requestSnapshotForElement:attributes:parameters:error:)]) {
85
- id result = [FBAXClient requestSnapshotForElement:element
86
- attributes:attributes
87
- parameters:[parameters copy]
88
- error:error];
89
- XCElementSnapshot *snapshot = [result valueForKey:@"_rootElementSnapshot"];
90
- return nil == snapshot ? result : snapshot;
91
- }
92
- return [FBAXClient snapshotForElement:element
93
- attributes:attributes
94
- parameters:[parameters copy]
95
- 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;
96
87
  }
97
88
 
98
89
  - (NSArray<XCAccessibilityElement *> *)activeApplications
@@ -119,27 +110,14 @@ static id FBAXClient = nil;
119
110
  - (NSDictionary *)attributesForElement:(XCAccessibilityElement *)element
120
111
  attributes:(NSArray *)attributes
121
112
  {
122
- if ([FBAXClient respondsToSelector:@selector(attributesForElement:attributes:error:)]) {
123
- NSError *error = nil;
124
- NSDictionary* result = [FBAXClient attributesForElement:element
125
- attributes:attributes
126
- error:&error];
127
- if (error) {
128
- [FBLogger logFmt:@"Cannot retrieve element attribute(s) %@. Original error: %@", attributes, error.description];
129
- }
130
- 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];
131
119
  }
132
- return [FBAXClient attributesForElement:element attributes:attributes];
133
- }
134
-
135
- - (BOOL)hasProcessTracker
136
- {
137
- static BOOL hasTracker;
138
- static dispatch_once_t onceToken;
139
- dispatch_once(&onceToken, ^{
140
- hasTracker = [FBAXClient respondsToSelector:@selector(applicationProcessTracker)];
141
- });
142
- return hasTracker;
120
+ return result;
143
121
  }
144
122
 
145
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;
@@ -34,8 +34,6 @@ NS_ASSUME_NONNULL_BEGIN
34
34
  */
35
35
  @interface XCElementSnapshot (FBCompatibility)
36
36
 
37
- - (nullable XCElementSnapshot *)fb_rootElement;
38
-
39
37
  + (nullable SEL)fb_attributesForElementSnapshotKeyPathsSelector;
40
38
 
41
39
  @end
@@ -93,11 +91,6 @@ extern NSString *const FBApplicationMethodNotSupportedException;
93
91
  */
94
92
  - (nullable XCElementSnapshot *)fb_uniqueSnapshotWithError:(NSError **)error;
95
93
 
96
- /**
97
- @returns YES if the element supports unique snapshots retrieval
98
- */
99
- - (BOOL)fb_isUniqueSnapshotSupported;
100
-
101
94
  @end
102
95
 
103
96
 
@@ -110,16 +103,6 @@ extern NSString *const FBApplicationMethodNotSupportedException;
110
103
 
111
104
  @interface XCUIElement (FBCompatibility)
112
105
 
113
- /**
114
- Enforces snapshot resolution of the destination element.
115
- !!! Do not cal this method on Xcode 11 or later due to performance considerations.
116
- Prefer using fb_takeSnapshot instead.
117
-
118
- @param error Contains the actual error if element resolution fails
119
- @returns YES if the element has been successfully resolved
120
- */
121
- - (BOOL)fb_resolveWithError:(NSError **)error;
122
-
123
106
  /**
124
107
  Determines whether current iOS SDK supports non modal elements inlusion into snapshots
125
108
 
@@ -19,21 +19,8 @@
19
19
 
20
20
  static const NSTimeInterval APP_STATE_CHANGE_TIMEOUT = 5.0;
21
21
 
22
- static BOOL FBShouldUseOldElementRootSelector = NO;
23
- static dispatch_once_t onceRootElementToken;
24
22
  @implementation XCElementSnapshot (FBCompatibility)
25
23
 
26
- - (XCElementSnapshot *)fb_rootElement
27
- {
28
- dispatch_once(&onceRootElementToken, ^{
29
- FBShouldUseOldElementRootSelector = [self respondsToSelector:@selector(_rootElement)];
30
- });
31
- if (FBShouldUseOldElementRootSelector) {
32
- return [self _rootElement];
33
- }
34
- return [self rootElement];
35
- }
36
-
37
24
  + (id)fb_axAttributesForElementSnapshotKeyPathsIOS:(id)arg1
38
25
  {
39
26
  return [self.class axAttributesForElementSnapshotKeyPaths:arg1 isMacOS:NO];
@@ -44,9 +31,7 @@ static dispatch_once_t onceRootElementToken;
44
31
  static SEL attributesForElementSnapshotKeyPathsSelector = nil;
45
32
  static dispatch_once_t attributesForElementSnapshotKeyPathsSelectorToken;
46
33
  dispatch_once(&attributesForElementSnapshotKeyPathsSelectorToken, ^{
47
- if ([self.class respondsToSelector:@selector(snapshotAttributesForElementSnapshotKeyPaths:)]) {
48
- attributesForElementSnapshotKeyPathsSelector = @selector(snapshotAttributesForElementSnapshotKeyPaths:);
49
- } else if ([self.class respondsToSelector:@selector(axAttributesForElementSnapshotKeyPaths:)]) {
34
+ if ([self.class respondsToSelector:@selector(axAttributesForElementSnapshotKeyPaths:)]) {
50
35
  attributesForElementSnapshotKeyPathsSelector = @selector(axAttributesForElementSnapshotKeyPaths:);
51
36
  } else if ([self.class respondsToSelector:@selector(axAttributesForElementSnapshotKeyPaths:isMacOS:)]) {
52
37
  attributesForElementSnapshotKeyPathsSelector = @selector(fb_axAttributesForElementSnapshotKeyPathsIOS:);
@@ -60,22 +45,14 @@ static dispatch_once_t onceRootElementToken;
60
45
 
61
46
  NSString *const FBApplicationMethodNotSupportedException = @"FBApplicationMethodNotSupportedException";
62
47
 
63
- static BOOL FBShouldUseOldAppWithPIDSelector = NO;
64
- static dispatch_once_t onceAppWithPIDToken;
65
48
  @implementation XCUIApplication (FBCompatibility)
66
49
 
67
50
  + (instancetype)fb_applicationWithPID:(pid_t)processID
68
51
  {
69
- dispatch_once(&onceAppWithPIDToken, ^{
70
- FBShouldUseOldAppWithPIDSelector = [XCUIApplication respondsToSelector:@selector(appWithPID:)];
71
- });
72
52
  if (0 == processID) {
73
53
  return nil;
74
54
  }
75
55
 
76
- if (FBShouldUseOldAppWithPIDSelector) {
77
- return [self appWithPID:processID];
78
- }
79
56
  return [self applicationWithPID:processID];
80
57
  }
81
58
 
@@ -105,16 +82,6 @@ static dispatch_once_t onceAppWithPIDToken;
105
82
 
106
83
  @implementation XCUIElementQuery (FBCompatibility)
107
84
 
108
- - (BOOL)fb_isUniqueSnapshotSupported
109
- {
110
- static dispatch_once_t onceToken;
111
- static BOOL isUniqueMatchingSnapshotAvailable;
112
- dispatch_once(&onceToken, ^{
113
- isUniqueMatchingSnapshotAvailable = [self respondsToSelector:@selector(uniqueMatchingSnapshotWithError:)];
114
- });
115
- return isUniqueMatchingSnapshotAvailable;
116
- }
117
-
118
85
  - (XCElementSnapshot *)fb_uniqueSnapshotWithError:(NSError **)error
119
86
  {
120
87
  return [self uniqueMatchingSnapshotWithError:error];
@@ -140,27 +107,6 @@ static dispatch_once_t onceAppWithPIDToken;
140
107
 
141
108
  @implementation XCUIElement (FBCompatibility)
142
109
 
143
- - (BOOL)fb_resolveWithError:(NSError **)error
144
- {
145
- @try {
146
- // The order here matters
147
- if ([self respondsToSelector:@selector(resolveOrRaiseTestFailure)]) {
148
- [self resolveOrRaiseTestFailure];
149
- return YES;
150
- } else if ([self respondsToSelector:@selector(resolve:)]) {
151
- return [self resolve:error];
152
- } else if ([self respondsToSelector:@selector(resolve)]) {
153
- [self resolve];
154
- return nil != self.lastSnapshot;
155
- }
156
- } @catch (NSException *e) {
157
- if (nil != e.reason) {
158
- return [[FBErrorBuilder.builder withDescription:(NSString *)e.reason] buildError:error];
159
- }
160
- }
161
- return [[FBErrorBuilder.builder withDescription:@"Cannot find a matching method to resolve elements. Please contact Appium developers"] buildError:error];
162
- }
163
-
164
110
  + (BOOL)fb_supportsNonModalElementsInclusion
165
111
  {
166
112
  static dispatch_once_t hasIncludingNonModalElements;
Binary file
@@ -164,6 +164,11 @@
164
164
  FBAssertWaitTillBecomesTrue(alert.isPresent);
165
165
 
166
166
  XCTAssertTrue([alert.text containsString:@"Would Like to Access Your Photos"]);
167
+ // iOS 15 has different UI flow
168
+ if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"15.0")) {
169
+ [[FBAlert alertWithApplication:self.testedApplication] dismissWithError:nil];
170
+ [self.testedApplication.buttons[@"Cancel"] tap];
171
+ }
167
172
  }
168
173
 
169
174
  - (void)testGPSAccessAlert
@@ -11,6 +11,7 @@
11
11
 
12
12
  #import "FBIntegrationTestCase.h"
13
13
 
14
+ #import "FBMacros.h"
14
15
  #import "XCUIElement.h"
15
16
  #import "XCUIApplication+FBTouchAction.h"
16
17
  #import "FBTestMacros.h"
@@ -132,6 +133,12 @@
132
133
 
133
134
  - (void)testMultiTouchWithMultiTaps
134
135
  {
136
+ if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"15.0")) {
137
+ // Does not work on iOS 15.
138
+ // It tapped two times, but one was touch count was one. Not two finguer taps.
139
+ return;
140
+ }
141
+
135
142
  XCUIElement *touchableView = self.testedApplication.otherElements[@"touchableView"];
136
143
  XCTAssertNotNil(touchableView);
137
144
  NSArray<NSArray<NSDictionary<NSString *, id> *>*> *gesture =
@@ -194,6 +194,14 @@
194
194
 
195
195
  - (void)testDoubleTap
196
196
  {
197
+ if ([UIDevice.currentDevice userInterfaceIdiom] == UIUserInterfaceIdiomPad &&
198
+ SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"15.0")) {
199
+ // "tap the element" does not work on iPadOS simulator after change the rotation in iOS 15
200
+ // while selecting the element worked. (I confirmed with getting an element screenshot that
201
+ // the FBShowAlertButtonName was actually selected after changing the orientation.)
202
+ return;
203
+ }
204
+
197
205
  NSArray<NSDictionary<NSString *, id> *> *gesture =
198
206
  @[@{
199
207
  @"action": @"tap",
@@ -208,6 +216,13 @@
208
216
 
209
217
  - (void)testPress
210
218
  {
219
+ if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"15.0")) {
220
+ // Does not work on iOS 15.0.
221
+ // The same action tap the FBShowAlertButtonName after rotating the screen
222
+ // worked with W3C actions. `.click` action did not work.
223
+ return;
224
+ }
225
+
211
226
  NSArray<NSDictionary<NSString *, id> *> *gesture =
212
227
  @[@{
213
228
  @"action": @"press",
@@ -271,6 +286,10 @@
271
286
 
272
287
  - (void)testForcePress
273
288
  {
289
+ if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"15.0")) {
290
+ // Does not work on iOS 15.
291
+ return;
292
+ }
274
293
  NSArray<NSDictionary<NSString *, id> *> *gesture =
275
294
  @[@{
276
295
  @"action": @"press",
@@ -51,6 +51,10 @@
51
51
  XCTAssertTrue(image.size.width > image.size.height);
52
52
 
53
53
  XCUIScreen *mainScreen = XCUIScreen.mainScreen;
54
+ // Note about iPadOS 15.0 environment.
55
+ // The 'button.screenshot.image' (by XCTest) had a white image while 'image' had
56
+ // expected FBShowAlertButtonName area image by WebDriverAgent.
57
+ // It seems the native XCTest element screenshot has an issue on iPadOS.
54
58
  UIImage *buttonScreenshot = button.screenshot.image;
55
59
  XCTAssertEqualWithAccuracy(buttonScreenshot.size.height * mainScreen.scale,
56
60
  image.size.height,
@@ -17,19 +17,38 @@
17
17
 
18
18
  @interface FBElementSwipingTests : FBIntegrationTestCase
19
19
  @property (nonatomic, strong) XCUIElement *scrollView;
20
+ - (void)openScrollView;
20
21
  @end
21
22
 
22
23
  @implementation FBElementSwipingTests
23
24
 
25
+ - (void)openScrollView
26
+ {
27
+ [self launchApplication];
28
+ [self goToScrollPageWithCells:YES];
29
+ self.scrollView = [[self.testedApplication.query descendantsMatchingType:XCUIElementTypeAny] matchingIdentifier:@"scrollView"].element;
30
+ }
31
+
24
32
  - (void)setUp
25
33
  {
26
34
  [super setUp];
27
- static dispatch_once_t onceToken;
28
- dispatch_once(&onceToken, ^{
29
- [self launchApplication];
30
- [self goToScrollPageWithCells:YES];
31
- self.scrollView = [[self.testedApplication.query descendantsMatchingType:XCUIElementTypeAny] matchingIdentifier:@"scrollView"].element;
32
- });
35
+ if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"15.0")) {
36
+ [self openScrollView];
37
+ } else {
38
+ static dispatch_once_t onceToken;
39
+ dispatch_once(&onceToken, ^{
40
+ [self openScrollView];
41
+ });
42
+ }
43
+ }
44
+
45
+ - (void)tearDown
46
+ {
47
+ if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"15.0")) {
48
+ // Move to top page once to reset the scroll place
49
+ // since iOS 15 seems cannot handle cell visibility well when the view keps the view
50
+ [self.testedApplication terminate];
51
+ }
33
52
  }
34
53
 
35
54
  - (void)testSwipeUp
@@ -55,3 +74,49 @@
55
74
  }
56
75
 
57
76
  @end
77
+
78
+ @interface FBElementSwipingApplicationTests : FBIntegrationTestCase
79
+ @property (nonatomic, strong) XCUIElement *scrollView;
80
+ - (void)openScrollView;
81
+ @end
82
+
83
+ @implementation FBElementSwipingApplicationTests
84
+
85
+ - (void)openScrollView
86
+ {
87
+ [self launchApplication];
88
+ [self goToScrollPageWithCells:YES];
89
+ }
90
+
91
+ - (void)setUp
92
+ {
93
+ [super setUp];
94
+ static dispatch_once_t onceToken;
95
+ dispatch_once(&onceToken, ^{
96
+ [self openScrollView];
97
+ });
98
+ }
99
+
100
+ - (void)testSwipeUp
101
+ {
102
+ [self.testedApplication fb_swipeWithDirection:@"up" velocity:nil];
103
+ FBAssertInvisibleCell(@"0");
104
+ }
105
+
106
+ - (void)testSwipeDown
107
+ {
108
+ [self.testedApplication fb_swipeWithDirection:@"up" velocity:nil];
109
+ FBAssertInvisibleCell(@"0");
110
+ [self.testedApplication fb_swipeWithDirection:@"down" velocity:nil];
111
+ FBAssertVisibleCell(@"0");
112
+ }
113
+
114
+ - (void)testSwipeDownWithVelocity
115
+ {
116
+ [self.testedApplication fb_swipeWithDirection:@"up" velocity:@2500];
117
+ FBAssertInvisibleCell(@"0");
118
+ [self.testedApplication fb_swipeWithDirection:@"down" velocity:@2500];
119
+ FBAssertVisibleCell(@"0");
120
+ }
121
+
122
+ @end
@@ -30,7 +30,9 @@
30
30
  [self goToSpringBoardFirstPage];
31
31
 
32
32
  // Check Icons on first screen
33
- XCTAssertTrue(self.springboard.icons[@"Calendar"].fb_isVisible);
33
+ // Note: Calender app exits 2 (an app icon + a widget) exist on the home screen
34
+ // on iOS 15+. The firstMatch is for it.
35
+ XCTAssertTrue(self.springboard.icons[@"Calendar"].firstMatch.fb_isVisible);
34
36
  XCTAssertTrue(self.springboard.icons[@"Reminders"].fb_isVisible);
35
37
 
36
38
  // Check Icons on second screen screen
@@ -11,6 +11,7 @@
11
11
 
12
12
  #import "FBIntegrationTestCase.h"
13
13
 
14
+ #import "FBMacros.h"
14
15
  #import "FBElementCache.h"
15
16
  #import "FBTestMacros.h"
16
17
  #import "XCUIDevice+FBRotation.h"
@@ -53,6 +54,11 @@
53
54
 
54
55
  - (void)testForceTap
55
56
  {
57
+ if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"15.0")) {
58
+ // Does not work on iOS 15.
59
+ return;
60
+ }
61
+
56
62
  [self verifyForceTapWithOrientation:UIDeviceOrientationPortrait];
57
63
  }
58
64