appium-webdriveragent 5.15.6 → 5.15.7

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 (46) hide show
  1. package/CHANGELOG.md +12 -0
  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+FBTVFocuse.m +2 -2
  10. package/WebDriverAgentLib/Commands/FBAlertViewCommands.m +4 -4
  11. package/WebDriverAgentLib/Commands/FBCustomCommands.m +2 -2
  12. package/WebDriverAgentLib/Commands/FBDebugCommands.m +2 -3
  13. package/WebDriverAgentLib/Commands/FBElementCommands.m +2 -4
  14. package/WebDriverAgentLib/Commands/FBFindElementCommands.m +0 -1
  15. package/WebDriverAgentLib/Commands/FBOrientationCommands.m +9 -8
  16. package/WebDriverAgentLib/Commands/FBSessionCommands.m +7 -9
  17. package/WebDriverAgentLib/Commands/FBTouchActionCommands.m +0 -1
  18. package/WebDriverAgentLib/FBAlert.m +3 -3
  19. package/WebDriverAgentLib/Routing/FBSession.h +13 -14
  20. package/WebDriverAgentLib/Routing/FBSession.m +49 -46
  21. package/WebDriverAgentLib/Utilities/FBAlertsMonitor.m +3 -3
  22. package/WebDriverAgentLib/Utilities/FBKeyboard.m +6 -5
  23. package/WebDriverAgentLib/Utilities/FBMjpegServer.m +0 -1
  24. package/WebDriverAgentLib/Utilities/FBPasteboard.m +2 -2
  25. package/WebDriverAgentLib/Utilities/FBScreen.m +1 -2
  26. package/WebDriverAgentLib/Utilities/FBTVNavigationTracker.m +1 -2
  27. package/WebDriverAgentLib/Utilities/FBXCodeCompatibility.h +0 -33
  28. package/WebDriverAgentLib/Utilities/FBXCodeCompatibility.m +2 -40
  29. package/WebDriverAgentLib/WebDriverAgentLib.h +0 -1
  30. package/WebDriverAgentTests/IntegrationTests/FBAutoAlertsHandlerTests.m +2 -3
  31. package/WebDriverAgentTests/IntegrationTests/FBElementVisibilityTests.m +0 -1
  32. package/WebDriverAgentTests/IntegrationTests/FBIntegrationTestCase.h +1 -3
  33. package/WebDriverAgentTests/IntegrationTests/FBIntegrationTestCase.m +5 -5
  34. package/WebDriverAgentTests/IntegrationTests/FBSafariAlertTests.m +1 -2
  35. package/WebDriverAgentTests/IntegrationTests/FBSessionIntegrationTests.m +11 -10
  36. package/WebDriverAgentTests/IntegrationTests/FBTapTest.m +0 -1
  37. package/WebDriverAgentTests/IntegrationTests/FBW3CMultiTouchActionsIntegrationTests.m +0 -1
  38. package/WebDriverAgentTests/IntegrationTests/XCUIApplicationHelperTests.m +8 -8
  39. package/WebDriverAgentTests/IntegrationTests/XCUIDeviceHelperTests.m +5 -4
  40. package/WebDriverAgentTests/IntegrationTests/XCUIElementHelperIntegrationTests.m +0 -1
  41. package/WebDriverAgentTests/UnitTests/Doubles/{FBApplicationDouble.h → XCUIApplicationDouble.h} +1 -1
  42. package/WebDriverAgentTests/UnitTests/Doubles/{FBApplicationDouble.m → XCUIApplicationDouble.m} +3 -3
  43. package/WebDriverAgentTests/UnitTests/FBSessionTests.m +3 -3
  44. package/package.json +2 -2
  45. package/WebDriverAgentLib/FBApplication.h +0 -49
  46. package/WebDriverAgentLib/FBApplication.m +0 -185
@@ -9,7 +9,6 @@
9
9
 
10
10
  #import "FBSessionCommands.h"
11
11
 
12
- #import "FBApplication.h"
13
12
  #import "FBCapabilities.h"
14
13
  #import "FBConfiguration.h"
15
14
  #import "FBLogger.h"
@@ -17,7 +16,6 @@
17
16
  #import "FBRouteRequest.h"
18
17
  #import "FBSession.h"
19
18
  #import "FBSettings.h"
20
- #import "FBApplication.h"
21
19
  #import "FBRuntimeUtils.h"
22
20
  #import "FBActiveAppDetectionPoint.h"
23
21
  #import "FBXCodeCompatibility.h"
@@ -138,15 +136,15 @@
138
136
  }
139
137
 
140
138
  NSString *bundleID = capabilities[FB_CAP_BUNDLE_ID];
141
- FBApplication *app = nil;
139
+ XCUIApplication *app = nil;
142
140
  if (bundleID != nil) {
143
- app = [[FBApplication alloc] initWithBundleIdentifier:bundleID];
141
+ app = [[XCUIApplication alloc] initWithBundleIdentifier:bundleID];
144
142
  BOOL forceAppLaunch = YES;
145
143
  if (nil != capabilities[FB_CAP_FORCE_APP_LAUNCH]) {
146
144
  forceAppLaunch = [capabilities[FB_CAP_FORCE_APP_LAUNCH] boolValue];
147
145
  }
148
- NSUInteger appState = [app fb_state];
149
- BOOL isAppRunning = appState >= 2;
146
+ XCUIApplicationState appState = app.state;
147
+ BOOL isAppRunning = appState >= XCUIApplicationStateRunningBackground;
150
148
  if (!isAppRunning || (isAppRunning && forceAppLaunch)) {
151
149
  app.fb_shouldWaitForQuiescence = nil == capabilities[FB_CAP_SHOULD_WAIT_FOR_QUIESCENCE]
152
150
  || [capabilities[FB_CAP_SHOULD_WAIT_FOR_QUIESCENCE] boolValue];
@@ -158,8 +156,8 @@
158
156
  return FBResponseWithStatus([FBCommandStatus sessionNotCreatedError:errorMsg
159
157
  traceback:nil]);
160
158
  }
161
- } else if (appState < 4 && !forceAppLaunch) {
162
- [app fb_activate];
159
+ } else if (appState == XCUIApplicationStateRunningBackground && !forceAppLaunch) {
160
+ [app activate];
163
161
  }
164
162
  }
165
163
 
@@ -265,7 +263,7 @@
265
263
 
266
264
  + (id<FBResponsePayload>)handleGetHealthCheck:(FBRouteRequest *)request
267
265
  {
268
- if (![[XCUIDevice sharedDevice] fb_healthCheckWithApplication:[FBApplication fb_activeApplication]]) {
266
+ if (![[XCUIDevice sharedDevice] fb_healthCheckWithApplication:[XCUIApplication fb_activeApplication]]) {
269
267
  return FBResponseWithUnknownErrorFormat(@"Health check failed");
270
268
  }
271
269
  return FBResponseWithOK();
@@ -9,7 +9,6 @@
9
9
 
10
10
  #import "FBTouchActionCommands.h"
11
11
 
12
- #import "FBApplication.h"
13
12
  #import "FBRoute.h"
14
13
  #import "FBRouteRequest.h"
15
14
  #import "FBSession.h"
@@ -9,12 +9,12 @@
9
9
 
10
10
  #import "FBAlert.h"
11
11
 
12
- #import "FBApplication.h"
13
12
  #import "FBConfiguration.h"
14
13
  #import "FBErrorBuilder.h"
15
14
  #import "FBLogger.h"
16
15
  #import "FBXCElementSnapshotWrapper+Helpers.h"
17
16
  #import "FBXCodeCompatibility.h"
17
+ #import "XCUIApplication.h"
18
18
  #import "XCUIApplication+FBAlert.h"
19
19
  #import "XCUIElement+FBClassChain.h"
20
20
  #import "XCUIElement+FBTyping.h"
@@ -263,8 +263,8 @@
263
263
  if (nil == self.element) {
264
264
  self.element = self.application.fb_alertElement;
265
265
  if (nil == self.element) {
266
- FBApplication *systemApp = FBApplication.fb_systemApplication;
267
- for (FBApplication *activeApp in FBApplication.fb_activeApplications) {
266
+ XCUIApplication *systemApp = XCUIApplication.fb_systemApplication;
267
+ for (XCUIApplication *activeApp in XCUIApplication.fb_activeApplications) {
268
268
  if (systemApp.processID == activeApp.processID) {
269
269
  self.element = activeApp.fb_alertElement;
270
270
  break;
@@ -9,8 +9,8 @@
9
9
 
10
10
  #import <Foundation/Foundation.h>
11
11
 
12
- @class FBApplication;
13
12
  @class FBElementCache;
13
+ @class XCUIApplication;
14
14
 
15
15
  NS_ASSUME_NONNULL_BEGIN
16
16
 
@@ -20,16 +20,16 @@ NS_ASSUME_NONNULL_BEGIN
20
20
  @interface FBSession : NSObject
21
21
 
22
22
  /*! Application tested during that session */
23
- @property (nonatomic, strong, readonly) FBApplication *activeApplication;
23
+ @property (nonatomic, readonly) XCUIApplication *activeApplication;
24
24
 
25
25
  /*! Session's identifier */
26
- @property (nonatomic, copy, readonly) NSString *identifier;
26
+ @property (nonatomic, readonly) NSString *identifier;
27
27
 
28
28
  /*! Element cache related to that session */
29
- @property (nonatomic, strong, readonly) FBElementCache *elementCache;
29
+ @property (nonatomic, readonly) FBElementCache *elementCache;
30
30
 
31
31
  /*! The identifier of the active application */
32
- @property (nonatomic, copy) NSString *defaultActiveApplication;
32
+ @property (nonatomic) NSString *defaultActiveApplication;
33
33
 
34
34
  /*! The action to apply to unexpected alerts. Either "accept"/"dismiss" or nil/empty string (by default) to do nothing */
35
35
  @property (nonatomic, nullable) NSString *defaultAlertAction;
@@ -57,7 +57,7 @@ NS_ASSUME_NONNULL_BEGIN
57
57
  @param application The application that we want to create session for
58
58
  @return new session
59
59
  */
60
- + (instancetype)initWithApplication:(nullable FBApplication *)application;
60
+ + (instancetype)initWithApplication:(nullable XCUIApplication *)application;
61
61
 
62
62
  /**
63
63
  Creates and saves new session for application with default alert handling behaviour
@@ -66,7 +66,8 @@ NS_ASSUME_NONNULL_BEGIN
66
66
  @param defaultAlertAction The default reaction to on-screen alert. Either 'accept' or 'dismiss'
67
67
  @return new session
68
68
  */
69
- + (instancetype)initWithApplication:(nullable FBApplication *)application defaultAlertAction:(NSString *)defaultAlertAction;
69
+ + (instancetype)initWithApplication:(nullable XCUIApplication *)application
70
+ defaultAlertAction:(NSString *)defaultAlertAction;
70
71
 
71
72
  /**
72
73
  Kills application associated with that session and removes session
@@ -82,12 +83,11 @@ NS_ASSUME_NONNULL_BEGIN
82
83
  @param arguments The optional array of application command line arguments. The arguments are going to be applied if the application was not running before.
83
84
  @param environment The optional dictionary of environment variables for the application, which is going to be executed. The environment variables are going to be applied if the application was not running before.
84
85
  @return The application instance
85
- @throws FBApplicationMethodNotSupportedException if the method is not supported with the current XCTest SDK
86
86
  */
87
- - (FBApplication *)launchApplicationWithBundleId:(NSString *)bundleIdentifier
88
- shouldWaitForQuiescence:(nullable NSNumber *)shouldWaitForQuiescence
89
- arguments:(nullable NSArray<NSString *> *)arguments
90
- environment:(nullable NSDictionary <NSString *, NSString *> *)environment;
87
+ - (XCUIApplication *)launchApplicationWithBundleId:(NSString *)bundleIdentifier
88
+ shouldWaitForQuiescence:(nullable NSNumber *)shouldWaitForQuiescence
89
+ arguments:(nullable NSArray<NSString *> *)arguments
90
+ environment:(nullable NSDictionary <NSString *, NSString *> *)environment;
91
91
 
92
92
  /**
93
93
  Activate an application with given bundle identifier in scope of current session.
@@ -95,9 +95,8 @@ NS_ASSUME_NONNULL_BEGIN
95
95
 
96
96
  @param bundleIdentifier Valid bundle identifier of the application to be activated
97
97
  @return The application instance
98
- @throws FBApplicationMethodNotSupportedException if the method is not supported with the current XCTest SDK
99
98
  */
100
- - (FBApplication *)activateApplicationWithBundleId:(NSString *)bundleIdentifier;
99
+ - (XCUIApplication *)activateApplicationWithBundleId:(NSString *)bundleIdentifier;
101
100
 
102
101
  /**
103
102
  Terminate an application with the given bundle id. The application should be previously
@@ -14,7 +14,6 @@
14
14
 
15
15
  #import "FBXCAccessibilityElement.h"
16
16
  #import "FBAlertsMonitor.h"
17
- #import "FBApplication.h"
18
17
  #import "FBConfiguration.h"
19
18
  #import "FBElementCache.h"
20
19
  #import "FBExceptions.h"
@@ -31,7 +30,7 @@
31
30
  NSString *const FBDefaultApplicationAuto = @"auto";
32
31
 
33
32
  @interface FBSession ()
34
- @property (nonatomic) NSString *testedApplicationBundleId;
33
+ @property (nullable, nonatomic) XCUIApplication *testedApplication;
35
34
  @property (nonatomic) BOOL isTestedApplicationExpectedToRun;
36
35
  @property (nonatomic) BOOL shouldAppsWaitForQuiescence;
37
36
  @property (nonatomic, nullable) FBAlertsMonitor *alertsMonitor;
@@ -96,7 +95,7 @@ static FBSession *_activeSession = nil;
96
95
  return _activeSession;
97
96
  }
98
97
 
99
- + (instancetype)initWithApplication:(FBApplication *)application
98
+ + (instancetype)initWithApplication:(XCUIApplication *)application
100
99
  {
101
100
  FBSession *session = [FBSession new];
102
101
  session.useNativeCachingStrategy = YES;
@@ -105,10 +104,10 @@ static FBSession *_activeSession = nil;
105
104
  session.elementsVisibilityCache = [NSMutableDictionary dictionary];
106
105
  session.identifier = [[NSUUID UUID] UUIDString];
107
106
  session.defaultActiveApplication = FBDefaultApplicationAuto;
108
- session.testedApplicationBundleId = nil;
107
+ session.testedApplication = nil;
109
108
  session.isTestedApplicationExpectedToRun = nil != application && application.running;
110
109
  if (application) {
111
- session.testedApplicationBundleId = application.bundleID;
110
+ session.testedApplication = application;
112
111
  session.shouldAppsWaitForQuiescence = application.fb_shouldWaitForQuiescence;
113
112
  }
114
113
  session.elementCache = [FBElementCache new];
@@ -116,7 +115,7 @@ static FBSession *_activeSession = nil;
116
115
  return session;
117
116
  }
118
117
 
119
- + (instancetype)initWithApplication:(nullable FBApplication *)application
118
+ + (instancetype)initWithApplication:(nullable XCUIApplication *)application
120
119
  defaultAlertAction:(NSString *)defaultAlertAction
121
120
  {
122
121
  FBSession *session = [self.class initWithApplication:application];
@@ -138,81 +137,78 @@ static FBSession *_activeSession = nil;
138
137
  self.alertsMonitor = nil;
139
138
  }
140
139
 
141
- if (self.testedApplicationBundleId && [FBConfiguration shouldTerminateApp]
142
- && ![self.testedApplicationBundleId isEqualToString:FBApplication.fb_systemApplication.bundleID]) {
143
- FBApplication *app = [[FBApplication alloc] initWithBundleIdentifier:self.testedApplicationBundleId];
144
- if ([app running]) {
145
- @try {
146
- [app terminate];
147
- } @catch (NSException *e) {
148
- [FBLogger logFmt:@"%@", e.description];
149
- }
140
+ if (nil != self.testedApplication
141
+ && FBConfiguration.shouldTerminateApp
142
+ && self.testedApplication.running
143
+ && ![self.testedApplication fb_isSameAppAs:XCUIApplication.fb_systemApplication]) {
144
+ @try {
145
+ [self.testedApplication terminate];
146
+ } @catch (NSException *e) {
147
+ [FBLogger logFmt:@"%@", e.description];
150
148
  }
151
149
  }
152
150
 
153
151
  _activeSession = nil;
154
152
  }
155
153
 
156
- - (FBApplication *)activeApplication
154
+ - (XCUIApplication *)activeApplication
157
155
  {
156
+ if (nil != self.testedApplication) {
157
+ XCUIApplicationState testedAppState = self.testedApplication.state;
158
+ if (testedAppState >= XCUIApplicationStateRunningForeground) {
159
+ return (XCUIApplication *)self.testedApplication;
160
+ }
161
+ if (self.isTestedApplicationExpectedToRun && testedAppState <= XCUIApplicationStateNotRunning) {
162
+ NSString *description = [NSString stringWithFormat:@"The application under test with bundle id '%@' is not running, possibly crashed", self.testedApplication.bundleID];
163
+ @throw [NSException exceptionWithName:FBApplicationCrashedException reason:description userInfo:nil];
164
+ }
165
+ }
166
+
158
167
  NSString *defaultBundleId = [self.defaultActiveApplication isEqualToString:FBDefaultApplicationAuto]
159
168
  ? nil
160
169
  : self.defaultActiveApplication;
161
- FBApplication *application = [FBApplication fb_activeApplicationWithDefaultBundleId:defaultBundleId];
162
- FBApplication *testedApplication = nil;
163
- if (self.testedApplicationBundleId && self.isTestedApplicationExpectedToRun) {
164
- testedApplication = nil != application.bundleID && [application.bundleID isEqualToString:self.testedApplicationBundleId]
165
- ? application
166
- : [[FBApplication alloc] initWithBundleIdentifier:self.testedApplicationBundleId];
167
- }
168
- if (testedApplication && !testedApplication.running) {
169
- NSString *description = [NSString stringWithFormat:@"The application under test with bundle id '%@' is not running, possibly crashed", self.testedApplicationBundleId];
170
- [[NSException exceptionWithName:FBApplicationCrashedException reason:description userInfo:nil] raise];
171
- }
172
- return application;
170
+ return [XCUIApplication fb_activeApplicationWithDefaultBundleId:defaultBundleId];
173
171
  }
174
172
 
175
- - (FBApplication *)launchApplicationWithBundleId:(NSString *)bundleIdentifier
176
- shouldWaitForQuiescence:(nullable NSNumber *)shouldWaitForQuiescence
177
- arguments:(nullable NSArray<NSString *> *)arguments
178
- environment:(nullable NSDictionary <NSString *, NSString *> *)environment
173
+ - (XCUIApplication *)launchApplicationWithBundleId:(NSString *)bundleIdentifier
174
+ shouldWaitForQuiescence:(nullable NSNumber *)shouldWaitForQuiescence
175
+ arguments:(nullable NSArray<NSString *> *)arguments
176
+ environment:(nullable NSDictionary <NSString *, NSString *> *)environment
179
177
  {
180
- FBApplication *app = [[FBApplication alloc] initWithBundleIdentifier:bundleIdentifier];
178
+ XCUIApplication *app = [self makeApplicationWithBundleId:bundleIdentifier];
181
179
  if (nil == shouldWaitForQuiescence) {
182
180
  // Iherit the quiescence check setting from the main app under test by default
183
- app.fb_shouldWaitForQuiescence = nil != self.testedApplicationBundleId && self.shouldAppsWaitForQuiescence;
181
+ app.fb_shouldWaitForQuiescence = nil != self.testedApplication && self.shouldAppsWaitForQuiescence;
184
182
  } else {
185
183
  app.fb_shouldWaitForQuiescence = [shouldWaitForQuiescence boolValue];
186
184
  }
187
- if (app.fb_state < 2) {
185
+ if (!app.running) {
188
186
  app.launchArguments = arguments ?: @[];
189
187
  app.launchEnvironment = environment ?: @{};
190
188
  [app launch];
191
189
  } else {
192
- [app fb_activate];
190
+ [app activate];
193
191
  }
194
- if (nil != self.testedApplicationBundleId
195
- && [bundleIdentifier isEqualToString:(NSString *)self.testedApplicationBundleId]) {
192
+ if ([app fb_isSameAppAs:self.testedApplication]) {
196
193
  self.isTestedApplicationExpectedToRun = YES;
197
194
  }
198
195
  return app;
199
196
  }
200
197
 
201
- - (FBApplication *)activateApplicationWithBundleId:(NSString *)bundleIdentifier
198
+ - (XCUIApplication *)activateApplicationWithBundleId:(NSString *)bundleIdentifier
202
199
  {
203
- FBApplication *app = [[FBApplication alloc] initWithBundleIdentifier:bundleIdentifier];
204
- [app fb_activate];
200
+ XCUIApplication *app = [self makeApplicationWithBundleId:bundleIdentifier];
201
+ [app activate];
205
202
  return app;
206
203
  }
207
204
 
208
205
  - (BOOL)terminateApplicationWithBundleId:(NSString *)bundleIdentifier
209
206
  {
210
- FBApplication *app = [[FBApplication alloc] initWithBundleIdentifier:bundleIdentifier];
211
- if (nil != self.testedApplicationBundleId
212
- && [bundleIdentifier isEqualToString:(NSString *)self.testedApplicationBundleId]) {
207
+ XCUIApplication *app = [self makeApplicationWithBundleId:bundleIdentifier];
208
+ if ([app fb_isSameAppAs:self.testedApplication]) {
213
209
  self.isTestedApplicationExpectedToRun = NO;
214
210
  }
215
- if (app.fb_state >= 2) {
211
+ if (app.running) {
216
212
  [app terminate];
217
213
  return YES;
218
214
  }
@@ -221,7 +217,14 @@ static FBSession *_activeSession = nil;
221
217
 
222
218
  - (NSUInteger)applicationStateWithBundleId:(NSString *)bundleIdentifier
223
219
  {
224
- return [[FBApplication alloc] initWithBundleIdentifier:bundleIdentifier].fb_state;
220
+ return [self makeApplicationWithBundleId:bundleIdentifier].state;
221
+ }
222
+
223
+ - (XCUIApplication *)makeApplicationWithBundleId:(NSString *)bundleIdentifier
224
+ {
225
+ return nil != self.testedApplication && [bundleIdentifier isEqualToString:(NSString *)self.testedApplication.bundleID]
226
+ ? self.testedApplication
227
+ : [[XCUIApplication alloc] initWithBundleIdentifier:bundleIdentifier];
225
228
  }
226
229
 
227
230
  @end
@@ -10,9 +10,9 @@
10
10
  #import "FBAlertsMonitor.h"
11
11
 
12
12
  #import "FBAlert.h"
13
- #import "FBApplication.h"
14
13
  #import "FBLogger.h"
15
14
  #import "XCUIApplication+FBAlert.h"
15
+ #import "XCUIApplication+FBHelpers.h"
16
16
 
17
17
  static const NSTimeInterval FB_MONTORING_INTERVAL = 2.0;
18
18
 
@@ -49,8 +49,8 @@ static const NSTimeInterval FB_MONTORING_INTERVAL = 2.0;
49
49
  }
50
50
 
51
51
  dispatch_async(dispatch_get_main_queue(), ^{
52
- NSArray<FBApplication *> *activeApps = FBApplication.fb_activeApplications;
53
- for (FBApplication *activeApp in activeApps) {
52
+ NSArray<XCUIApplication *> *activeApps = XCUIApplication.fb_activeApplications;
53
+ for (XCUIApplication *activeApp in activeApps) {
54
54
  XCUIElement *alertElement = nil;
55
55
  @try {
56
56
  alertElement = activeApp.fb_alertElement;
@@ -9,8 +9,6 @@
9
9
 
10
10
  #import "FBKeyboard.h"
11
11
 
12
-
13
- #import "FBApplication.h"
14
12
  #import "FBConfiguration.h"
15
13
  #import "FBXCTestDaemonsProxy.h"
16
14
  #import "FBErrorBuilder.h"
@@ -25,10 +23,13 @@
25
23
 
26
24
  @implementation FBKeyboard
27
25
 
28
- + (BOOL)waitUntilVisibleForApplication:(XCUIApplication *)app timeout:(NSTimeInterval)timeout error:(NSError **)error
26
+ + (BOOL)waitUntilVisibleForApplication:(XCUIApplication *)app
27
+ timeout:(NSTimeInterval)timeout
28
+ error:(NSError **)error
29
29
  {
30
30
  BOOL (^isKeyboardVisible)(void) = ^BOOL(void) {
31
- if (!app.keyboard.exists) {
31
+ XCUIElement *keyboard = app.keyboards.fb_firstMatch;
32
+ if (nil == keyboard) {
32
33
  return NO;
33
34
  }
34
35
 
@@ -36,7 +37,7 @@
36
37
  NSDictionary *bindings) {
37
38
  return snapshot.label.length > 0;
38
39
  }];
39
- XCUIElement *firstKey = [[app.keyboard descendantsMatchingType:XCUIElementTypeKey]
40
+ XCUIElement *firstKey = [[keyboard descendantsMatchingType:XCUIElementTypeKey]
40
41
  matchingPredicate:keySearchPredicate].allElementsBoundByIndex.firstObject;
41
42
  return firstKey.exists && firstKey.hittable;
42
43
  };
@@ -13,7 +13,6 @@
13
13
  @import UniformTypeIdentifiers;
14
14
 
15
15
  #import "GCDAsyncSocket.h"
16
- #import "FBApplication.h"
17
16
  #import "FBConfiguration.h"
18
17
  #import "FBLogger.h"
19
18
  #import "FBScreenshot.h"
@@ -11,9 +11,9 @@
11
11
 
12
12
  #import <mach/mach_time.h>
13
13
  #import "FBAlert.h"
14
- #import "FBApplication.h"
15
14
  #import "FBErrorBuilder.h"
16
15
  #import "FBMacros.h"
16
+ #import "XCUIApplication+FBHelpers.h"
17
17
  #import "XCUIApplication+FBAlert.h"
18
18
 
19
19
  #define ALERT_TIMEOUT_SEC 30
@@ -101,7 +101,7 @@
101
101
  break;
102
102
  }
103
103
 
104
- XCUIElement *alertElement = FBApplication.fb_systemApplication.fb_alertElement;
104
+ XCUIElement *alertElement = XCUIApplication.fb_systemApplication.fb_alertElement;
105
105
  if (nil != alertElement) {
106
106
  FBAlert *alert = [FBAlert alertWithElement:alertElement];
107
107
  [alert acceptWithError:nil];
@@ -8,7 +8,6 @@
8
8
  */
9
9
 
10
10
  #import "FBScreen.h"
11
- #import "FBApplication.h"
12
11
  #import "XCUIElement+FBIsVisible.h"
13
12
  #import "FBXCodeCompatibility.h"
14
13
  #import "XCUIScreen.h"
@@ -22,7 +21,7 @@
22
21
 
23
22
  + (CGSize)statusBarSizeForApplication:(XCUIApplication *)application
24
23
  {
25
- XCUIApplication *app = FBApplication.fb_systemApplication;
24
+ XCUIApplication *app = XCUIApplication.fb_systemApplication;
26
25
  // Since iOS 13 the status bar is no longer part of the application, it’s part of the SpringBoard
27
26
  XCUIElement *mainStatusBar = app.statusBars.allElementsBoundByIndex.firstObject;
28
27
  if (nil == mainStatusBar) {
@@ -10,7 +10,6 @@
10
10
  #import "FBTVNavigationTracker.h"
11
11
  #import "FBTVNavigationTracker-Private.h"
12
12
 
13
- #import "FBApplication.h"
14
13
  #import "FBMathUtils.h"
15
14
  #import "XCUIElement+FBCaching.h"
16
15
  #import "XCUIElement+FBUtilities.h"
@@ -69,7 +68,7 @@
69
68
 
70
69
  - (FBTVDirection)directionToFocusedElement
71
70
  {
72
- XCUIElement *focused = FBApplication.fb_activeApplication.fb_focusedElement;
71
+ XCUIElement *focused = XCUIApplication.fb_activeApplication.fb_focusedElement;
73
72
 
74
73
  CGPoint focusedCenter = FBRectGetCenter(focused.wdFrame);
75
74
  FBTVNavigationItem *item = [self navigationItemWithElement:focused];
@@ -28,39 +28,6 @@ NSInteger FBTestmanagerdVersion(void);
28
28
 
29
29
  NS_ASSUME_NONNULL_BEGIN
30
30
 
31
- /**
32
- The exception happends if one tries to call application method,
33
- which is not supported in the current iOS version
34
- */
35
- extern NSString *const FBApplicationMethodNotSupportedException;
36
-
37
- @interface XCUIApplication (FBCompatibility)
38
-
39
- + (nullable instancetype)fb_applicationWithPID:(pid_t)processID;
40
-
41
- /**
42
- Get the state of the application. This method only returns reliable results on Xcode SDK 9+
43
-
44
- @return State value as enum item. See https://developer.apple.com/documentation/xctest/xcuiapplicationstate?language=objc for more details.
45
- */
46
- - (NSUInteger)fb_state;
47
-
48
- /**
49
- Activate the application by restoring it from the background.
50
- Nothing will happen if the application is already in foreground.
51
- This method is only supported since Xcode9.
52
-
53
- @throws FBTimeoutException if the app is still not active after the timeout
54
- */
55
- - (void)fb_activate;
56
-
57
- /**
58
- Terminate the application and wait until it disappears from the list of active apps
59
- */
60
- - (void)fb_terminate;
61
-
62
- @end
63
-
64
31
  @interface XCUIElementQuery (FBCompatibility)
65
32
 
66
33
  /* Performs short-circuit UI tree traversion in iOS 11+ to get the first element matched by the query. Equals to nil if no matching elements are found */
@@ -9,6 +9,7 @@
9
9
 
10
10
  #import "FBXCodeCompatibility.h"
11
11
 
12
+ #import "FBXCAXClientProxy.h"
12
13
  #import "FBConfiguration.h"
13
14
  #import "FBErrorBuilder.h"
14
15
  #import "FBLogger.h"
@@ -17,45 +18,6 @@
17
18
  #import "FBXCTestDaemonsProxy.h"
18
19
  #import "XCTestManager_ManagerInterface-Protocol.h"
19
20
 
20
- static const NSTimeInterval APP_STATE_CHANGE_TIMEOUT = 5.0;
21
-
22
- NSString *const FBApplicationMethodNotSupportedException = @"FBApplicationMethodNotSupportedException";
23
-
24
- @implementation XCUIApplication (FBCompatibility)
25
-
26
- + (instancetype)fb_applicationWithPID:(pid_t)processID
27
- {
28
- if (0 == processID) {
29
- return nil;
30
- }
31
-
32
- return [self applicationWithPID:processID];
33
- }
34
-
35
- - (void)fb_activate
36
- {
37
- [self activate];
38
- if (![self waitForState:XCUIApplicationStateRunningForeground timeout:APP_STATE_CHANGE_TIMEOUT / 2] || ![self fb_waitForAppElement:APP_STATE_CHANGE_TIMEOUT / 2]) {
39
- [FBLogger logFmt:@"The application '%@' is not running in foreground after %.2f seconds", self.bundleID, APP_STATE_CHANGE_TIMEOUT];
40
- }
41
- }
42
-
43
- - (void)fb_terminate
44
- {
45
- [self terminate];
46
- if (![self waitForState:XCUIApplicationStateNotRunning timeout:APP_STATE_CHANGE_TIMEOUT]) {
47
- [FBLogger logFmt:@"The active application is still '%@' after %.2f seconds timeout", self.bundleID, APP_STATE_CHANGE_TIMEOUT];
48
- }
49
- }
50
-
51
- - (NSUInteger)fb_state
52
- {
53
- return [[self valueForKey:@"state"] intValue];
54
- }
55
-
56
- @end
57
-
58
-
59
21
  @implementation XCUIElementQuery (FBCompatibility)
60
22
 
61
23
  - (XCElementSnapshot *)fb_uniqueSnapshotWithError:(NSError **)error
@@ -89,7 +51,7 @@ NSString *const FBApplicationMethodNotSupportedException = @"FBApplicationMethod
89
51
  static dispatch_once_t hasIncludingNonModalElements;
90
52
  static BOOL result;
91
53
  dispatch_once(&hasIncludingNonModalElements, ^{
92
- result = [FBApplication.fb_systemApplication.query respondsToSelector:@selector(includingNonModalElements)];
54
+ result = [XCUIApplication.fb_systemApplication.query respondsToSelector:@selector(includingNonModalElements)];
93
55
  });
94
56
  return result;
95
57
  }
@@ -16,7 +16,6 @@ FOUNDATION_EXPORT double WebDriverAgentLib_VersionNumber;
16
16
  FOUNDATION_EXPORT const unsigned char WebDriverAgentLib_VersionString[];
17
17
 
18
18
  #import <WebDriverAgentLib/FBAlert.h>
19
- #import <WebDriverAgentLib/FBApplication.h>
20
19
  #import <WebDriverAgentLib/FBCommandHandler.h>
21
20
  #import <WebDriverAgentLib/FBCommandStatus.h>
22
21
  #import <WebDriverAgentLib/FBConfiguration.h>
@@ -10,7 +10,6 @@
10
10
  #import <XCTest/XCTest.h>
11
11
 
12
12
  #import "FBIntegrationTestCase.h"
13
- #import "FBApplication.h"
14
13
  #import "FBMacros.h"
15
14
  #import "FBSession.h"
16
15
  #import "FBXCodeCompatibility.h"
@@ -50,7 +49,7 @@
50
49
  - (void)disabled_testAutoAcceptingOfAlerts
51
50
  {
52
51
  self.session = [FBSession
53
- initWithApplication:FBApplication.fb_activeApplication
52
+ initWithApplication:XCUIApplication.fb_activeApplication
54
53
  defaultAlertAction:@"accept"];
55
54
  for (int i = 0; i < 2; i++) {
56
55
  [self.testedApplication.buttons[FBShowAlertButtonName] tap];
@@ -63,7 +62,7 @@
63
62
  - (void)disabled_testAutoDismissingOfAlerts
64
63
  {
65
64
  self.session = [FBSession
66
- initWithApplication:FBApplication.fb_activeApplication
65
+ initWithApplication:XCUIApplication.fb_activeApplication
67
66
  defaultAlertAction:@"dismiss"];
68
67
  for (int i = 0; i < 2; i++) {
69
68
  [self.testedApplication.buttons[FBShowAlertButtonName] tap];
@@ -9,7 +9,6 @@
9
9
 
10
10
  #import <XCTest/XCTest.h>
11
11
 
12
- #import "FBApplication.h"
13
12
  #import "FBIntegrationTestCase.h"
14
13
  #import "FBMacros.h"
15
14
  #import "FBTestMacros.h"
@@ -9,8 +9,6 @@
9
9
 
10
10
  #import <XCTest/XCTest.h>
11
11
 
12
- #import "FBApplication.h"
13
-
14
12
  extern NSString *const FBShowAlertButtonName;
15
13
  extern NSString *const FBShowSheetAlertButtonName;
16
14
  extern NSString *const FBShowAlertForceTouchButtonName;
@@ -22,7 +20,7 @@ extern NSString *const FBTapsCountLabelIdentifier;
22
20
  */
23
21
  @interface FBIntegrationTestCase : XCTestCase
24
22
  @property (nonatomic, strong, readonly) XCUIApplication *testedApplication;
25
- @property (nonatomic, strong, readonly) FBApplication *springboard;
23
+ @property (nonatomic, strong, readonly) XCUIApplication *springboard;
26
24
 
27
25
  /**
28
26
  Launches application and resets side effects of testing like orientation etc.