appium-webdriveragent 5.15.9 → 6.0.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 (50) hide show
  1. package/CHANGELOG.md +10 -2
  2. package/PrivateHeaders/XCTest/XCUIApplication.h +0 -1
  3. package/WebDriverAgent.xcodeproj/project.pbxproj +6 -18
  4. package/WebDriverAgentLib/Categories/XCUIApplication+FBHelpers.h +38 -0
  5. package/WebDriverAgentLib/Categories/XCUIApplication+FBHelpers.m +148 -5
  6. package/WebDriverAgentLib/Categories/XCUIDevice+FBHelpers.m +1 -1
  7. package/WebDriverAgentLib/Categories/XCUIDevice+FBRotation.h +0 -1
  8. package/WebDriverAgentLib/Categories/XCUIDevice+FBRotation.m +5 -3
  9. package/WebDriverAgentLib/Categories/XCUIElement+FBSwiping.h +14 -0
  10. package/WebDriverAgentLib/Categories/XCUIElement+FBSwiping.m +27 -10
  11. package/WebDriverAgentLib/Categories/XCUIElement+FBTVFocuse.m +2 -2
  12. package/WebDriverAgentLib/Commands/FBAlertViewCommands.m +4 -4
  13. package/WebDriverAgentLib/Commands/FBCustomCommands.m +2 -2
  14. package/WebDriverAgentLib/Commands/FBDebugCommands.m +2 -3
  15. package/WebDriverAgentLib/Commands/FBElementCommands.m +113 -89
  16. package/WebDriverAgentLib/Commands/FBFindElementCommands.m +0 -1
  17. package/WebDriverAgentLib/Commands/FBOrientationCommands.m +9 -8
  18. package/WebDriverAgentLib/Commands/FBSessionCommands.m +7 -9
  19. package/WebDriverAgentLib/Commands/FBTouchActionCommands.m +0 -1
  20. package/WebDriverAgentLib/FBAlert.m +3 -3
  21. package/WebDriverAgentLib/Routing/FBSession.h +13 -14
  22. package/WebDriverAgentLib/Routing/FBSession.m +49 -46
  23. package/WebDriverAgentLib/Utilities/FBAlertsMonitor.m +3 -3
  24. package/WebDriverAgentLib/Utilities/FBKeyboard.m +6 -5
  25. package/WebDriverAgentLib/Utilities/FBMjpegServer.m +0 -1
  26. package/WebDriverAgentLib/Utilities/FBPasteboard.m +2 -2
  27. package/WebDriverAgentLib/Utilities/FBScreen.m +1 -2
  28. package/WebDriverAgentLib/Utilities/FBTVNavigationTracker.m +1 -2
  29. package/WebDriverAgentLib/Utilities/FBXCodeCompatibility.h +0 -33
  30. package/WebDriverAgentLib/Utilities/FBXCodeCompatibility.m +2 -40
  31. package/WebDriverAgentLib/WebDriverAgentLib.h +0 -1
  32. package/WebDriverAgentTests/IntegrationTests/FBAutoAlertsHandlerTests.m +2 -3
  33. package/WebDriverAgentTests/IntegrationTests/FBElementVisibilityTests.m +0 -1
  34. package/WebDriverAgentTests/IntegrationTests/FBIntegrationTestCase.h +1 -3
  35. package/WebDriverAgentTests/IntegrationTests/FBIntegrationTestCase.m +5 -5
  36. package/WebDriverAgentTests/IntegrationTests/FBSafariAlertTests.m +1 -2
  37. package/WebDriverAgentTests/IntegrationTests/FBSessionIntegrationTests.m +11 -10
  38. package/WebDriverAgentTests/IntegrationTests/FBTapTest.m +0 -1
  39. package/WebDriverAgentTests/IntegrationTests/FBW3CMultiTouchActionsIntegrationTests.m +0 -1
  40. package/WebDriverAgentTests/IntegrationTests/XCUIApplicationHelperTests.m +8 -8
  41. package/WebDriverAgentTests/IntegrationTests/XCUIDeviceHelperTests.m +5 -4
  42. package/WebDriverAgentTests/IntegrationTests/XCUIElementHelperIntegrationTests.m +0 -1
  43. package/WebDriverAgentTests/UnitTests/Doubles/{FBApplicationDouble.h → XCUIApplicationDouble.h} +1 -1
  44. package/WebDriverAgentTests/UnitTests/Doubles/{FBApplicationDouble.m → XCUIApplicationDouble.m} +3 -3
  45. package/WebDriverAgentTests/UnitTests/FBSessionTests.m +3 -3
  46. package/package.json +1 -1
  47. package/WebDriverAgent.xcodeproj/project.xcworkspace/xcuserdata/kazu.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  48. package/WebDriverAgent.xcodeproj/xcuserdata/kazu.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +0 -1342
  49. package/WebDriverAgentLib/FBApplication.h +0 -49
  50. package/WebDriverAgentLib/FBApplication.m +0 -185
@@ -1,49 +0,0 @@
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 <WebDriverAgentLib/XCUIApplication.h>
11
-
12
- NS_ASSUME_NONNULL_BEGIN
13
-
14
- @interface FBApplication : XCUIApplication
15
-
16
- /**
17
- Constructor used to get current active application
18
- */
19
- + (instancetype)fb_activeApplication;
20
-
21
- /**
22
- Constructor used to get current active application
23
-
24
- @param bundleId The bundle identifier of an app, which should be selected as active by default
25
- if it is present in the list of active applications
26
- */
27
- + (instancetype)fb_activeApplicationWithDefaultBundleId:(nullable NSString *)bundleId;
28
-
29
- /**
30
- Constructor used to get the system application (e.g. Springboard on iOS)
31
- */
32
- + (instancetype)fb_systemApplication;
33
-
34
- /**
35
- Retrieves the list of all currently active applications
36
- */
37
- + (NSArray<FBApplication *> *)fb_activeApplications;
38
-
39
- /**
40
- Switch to system app (called Springboard on iOS)
41
-
42
- @param error If there is an error, upon return contains an NSError object that describes the problem.
43
- @return YES if the operation succeeds, otherwise NO.
44
- */
45
- + (BOOL)fb_switchToSystemApplicationWithError:(NSError **)error;
46
-
47
- @end
48
-
49
- NS_ASSUME_NONNULL_END
@@ -1,185 +0,0 @@
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 "FBApplication.h"
11
-
12
- #import "FBXCAccessibilityElement.h"
13
- #import "FBLogger.h"
14
- #import "FBExceptions.h"
15
- #import "FBRunLoopSpinner.h"
16
- #import "FBMacros.h"
17
- #import "FBActiveAppDetectionPoint.h"
18
- #import "FBXCodeCompatibility.h"
19
- #import "FBXCTestDaemonsProxy.h"
20
- #import "XCUIApplication.h"
21
- #import "XCUIApplication+FBHelpers.h"
22
- #import "XCUIApplicationImpl.h"
23
- #import "XCUIApplicationProcess.h"
24
- #import "XCUIElement.h"
25
- #import "XCUIElementQuery.h"
26
- #import "FBXCAXClientProxy.h"
27
-
28
-
29
- static const NSTimeInterval APP_STATE_CHANGE_TIMEOUT = 5.0;
30
-
31
- @interface FBApplication ()
32
- @end
33
-
34
- @implementation FBApplication
35
-
36
- + (instancetype)fb_activeApplication
37
- {
38
- return [self fb_activeApplicationWithDefaultBundleId:nil];
39
- }
40
-
41
- + (NSArray<FBApplication *> *)fb_activeApplications
42
- {
43
- NSArray<id<FBXCAccessibilityElement>> *activeApplicationElements = [FBXCAXClientProxy.sharedClient activeApplications];
44
- NSMutableArray<FBApplication *> *result = [NSMutableArray array];
45
- if (activeApplicationElements.count > 0) {
46
- for (id<FBXCAccessibilityElement> applicationElement in activeApplicationElements) {
47
- FBApplication *app = [FBApplication fb_applicationWithPID:applicationElement.processIdentifier];
48
- if (nil != app) {
49
- [result addObject:app];
50
- }
51
- }
52
- }
53
- return result.count > 0 ? result.copy : @[self.class.fb_systemApplication];
54
- }
55
-
56
- + (instancetype)fb_activeApplicationWithDefaultBundleId:(nullable NSString *)bundleId
57
- {
58
- NSArray<id<FBXCAccessibilityElement>> *activeApplicationElements = [FBXCAXClientProxy.sharedClient activeApplications];
59
- id<FBXCAccessibilityElement> activeApplicationElement = nil;
60
- id<FBXCAccessibilityElement> currentElement = nil;
61
- if (nil != bundleId) {
62
- currentElement = FBActiveAppDetectionPoint.sharedInstance.axElement;
63
- if (nil != currentElement) {
64
- NSArray<NSDictionary *> *appInfos = [self fb_appsInfoWithAxElements:@[currentElement]];
65
- [FBLogger logFmt:@"Detected on-screen application: %@", appInfos.firstObject[@"bundleId"]];
66
- if ([[appInfos.firstObject objectForKey:@"bundleId"] isEqualToString:(id)bundleId]) {
67
- activeApplicationElement = currentElement;
68
- }
69
- }
70
- }
71
- if (nil == activeApplicationElement && activeApplicationElements.count > 1) {
72
- if (nil != bundleId) {
73
- NSArray<NSDictionary *> *appInfos = [self fb_appsInfoWithAxElements:activeApplicationElements];
74
- NSMutableArray<NSString *> *bundleIds = [NSMutableArray array];
75
- for (NSDictionary *appInfo in appInfos) {
76
- [bundleIds addObject:(NSString *)appInfo[@"bundleId"]];
77
- }
78
- [FBLogger logFmt:@"Detected system active application(s): %@", bundleIds];
79
- // Try to select the desired application first
80
- for (NSUInteger appIdx = 0; appIdx < appInfos.count; appIdx++) {
81
- if ([[[appInfos objectAtIndex:appIdx] objectForKey:@"bundleId"] isEqualToString:(id)bundleId]) {
82
- activeApplicationElement = [activeApplicationElements objectAtIndex:appIdx];
83
- break;
84
- }
85
- }
86
- }
87
- // Fall back to the "normal" algorithm if the desired application is either
88
- // not set or is not active
89
- if (nil == activeApplicationElement) {
90
- if (nil == currentElement) {
91
- currentElement = FBActiveAppDetectionPoint.sharedInstance.axElement;
92
- }
93
- if (nil == currentElement) {
94
- [FBLogger log:@"Cannot precisely detect the current application. Will use the system's recently active one"];
95
- if (nil == bundleId) {
96
- [FBLogger log:@"Consider changing the 'defaultActiveApplication' setting to the bundle identifier of the desired application under test"];
97
- }
98
- } else {
99
- for (id<FBXCAccessibilityElement> appElement in activeApplicationElements) {
100
- if (appElement.processIdentifier == currentElement.processIdentifier) {
101
- activeApplicationElement = appElement;
102
- break;
103
- }
104
- }
105
- }
106
- }
107
- }
108
-
109
- if (nil != activeApplicationElement) {
110
- FBApplication *application = [FBApplication fb_applicationWithPID:activeApplicationElement.processIdentifier];
111
- if (nil != application) {
112
- return application;
113
- }
114
- [FBLogger log:@"Cannot translate the active process identifier into an application object"];
115
- }
116
-
117
- if (activeApplicationElements.count > 0) {
118
- [FBLogger logFmt:@"Getting the most recent active application (out of %@ total items)", @(activeApplicationElements.count)];
119
- for (id<FBXCAccessibilityElement> appElement in activeApplicationElements) {
120
- FBApplication *application = [FBApplication fb_applicationWithPID:appElement.processIdentifier];
121
- if (nil != application) {
122
- return application;
123
- }
124
- }
125
- }
126
-
127
- [FBLogger log:@"Cannot retrieve any active applications. Assuming the system application is the active one"];
128
- return [self fb_systemApplication];
129
- }
130
-
131
- + (instancetype)fb_systemApplication
132
- {
133
- return [self fb_applicationWithPID:
134
- [[FBXCAXClientProxy.sharedClient systemApplication] processIdentifier]];
135
- }
136
-
137
- + (instancetype)applicationWithPID:(pid_t)processID
138
- {
139
- if ([NSProcessInfo processInfo].processIdentifier == processID) {
140
- return nil;
141
- }
142
- return (FBApplication *)[FBXCAXClientProxy.sharedClient monitoredApplicationWithProcessIdentifier:processID];
143
- }
144
-
145
- - (void)launch
146
- {
147
- [super launch];
148
- if (![self fb_waitForAppElement:APP_STATE_CHANGE_TIMEOUT]) {
149
- [FBLogger logFmt:@"The application '%@' is not running in foreground after %.2f seconds", self.bundleID, APP_STATE_CHANGE_TIMEOUT];
150
- }
151
- }
152
-
153
- - (void)terminate
154
- {
155
- [super terminate];
156
- if (![self waitForState:XCUIApplicationStateNotRunning timeout:APP_STATE_CHANGE_TIMEOUT]) {
157
- [FBLogger logFmt:@"The active application is still '%@' after %.2f seconds timeout", self.bundleID, APP_STATE_CHANGE_TIMEOUT];
158
- }
159
- }
160
-
161
- + (BOOL)fb_switchToSystemApplicationWithError:(NSError **)error
162
- {
163
- FBApplication *systemApp = self.fb_systemApplication;
164
- @try {
165
- if ([systemApp fb_state] < 2) {
166
- [systemApp launch];
167
- } else {
168
- [systemApp fb_activate];
169
- }
170
- } @catch (NSException *e) {
171
- return [[[FBErrorBuilder alloc]
172
- withDescription:nil == e ? @"Cannot open the home screen" : e.reason]
173
- buildError:error];
174
- }
175
- return [[[[FBRunLoopSpinner new]
176
- timeout:5]
177
- timeoutErrorMessage:@"Timeout waiting until the home screen is visible"]
178
- spinUntilTrue:^BOOL{
179
- FBApplication *activeApp = self.fb_activeApplication;
180
- return nil != activeApp && [activeApp.bundleID isEqualToString:systemApp.bundleID];
181
- }
182
- error:error];
183
- }
184
-
185
- @end