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.
- package/CHANGELOG.md +10 -2
- package/PrivateHeaders/XCTest/XCUIApplication.h +0 -1
- package/WebDriverAgent.xcodeproj/project.pbxproj +6 -18
- package/WebDriverAgentLib/Categories/XCUIApplication+FBHelpers.h +38 -0
- package/WebDriverAgentLib/Categories/XCUIApplication+FBHelpers.m +148 -5
- package/WebDriverAgentLib/Categories/XCUIDevice+FBHelpers.m +1 -1
- package/WebDriverAgentLib/Categories/XCUIDevice+FBRotation.h +0 -1
- package/WebDriverAgentLib/Categories/XCUIDevice+FBRotation.m +5 -3
- package/WebDriverAgentLib/Categories/XCUIElement+FBSwiping.h +14 -0
- package/WebDriverAgentLib/Categories/XCUIElement+FBSwiping.m +27 -10
- package/WebDriverAgentLib/Categories/XCUIElement+FBTVFocuse.m +2 -2
- package/WebDriverAgentLib/Commands/FBAlertViewCommands.m +4 -4
- package/WebDriverAgentLib/Commands/FBCustomCommands.m +2 -2
- package/WebDriverAgentLib/Commands/FBDebugCommands.m +2 -3
- package/WebDriverAgentLib/Commands/FBElementCommands.m +113 -89
- package/WebDriverAgentLib/Commands/FBFindElementCommands.m +0 -1
- package/WebDriverAgentLib/Commands/FBOrientationCommands.m +9 -8
- package/WebDriverAgentLib/Commands/FBSessionCommands.m +7 -9
- package/WebDriverAgentLib/Commands/FBTouchActionCommands.m +0 -1
- package/WebDriverAgentLib/FBAlert.m +3 -3
- package/WebDriverAgentLib/Routing/FBSession.h +13 -14
- package/WebDriverAgentLib/Routing/FBSession.m +49 -46
- package/WebDriverAgentLib/Utilities/FBAlertsMonitor.m +3 -3
- package/WebDriverAgentLib/Utilities/FBKeyboard.m +6 -5
- package/WebDriverAgentLib/Utilities/FBMjpegServer.m +0 -1
- package/WebDriverAgentLib/Utilities/FBPasteboard.m +2 -2
- package/WebDriverAgentLib/Utilities/FBScreen.m +1 -2
- package/WebDriverAgentLib/Utilities/FBTVNavigationTracker.m +1 -2
- package/WebDriverAgentLib/Utilities/FBXCodeCompatibility.h +0 -33
- package/WebDriverAgentLib/Utilities/FBXCodeCompatibility.m +2 -40
- package/WebDriverAgentLib/WebDriverAgentLib.h +0 -1
- package/WebDriverAgentTests/IntegrationTests/FBAutoAlertsHandlerTests.m +2 -3
- package/WebDriverAgentTests/IntegrationTests/FBElementVisibilityTests.m +0 -1
- package/WebDriverAgentTests/IntegrationTests/FBIntegrationTestCase.h +1 -3
- package/WebDriverAgentTests/IntegrationTests/FBIntegrationTestCase.m +5 -5
- package/WebDriverAgentTests/IntegrationTests/FBSafariAlertTests.m +1 -2
- package/WebDriverAgentTests/IntegrationTests/FBSessionIntegrationTests.m +11 -10
- package/WebDriverAgentTests/IntegrationTests/FBTapTest.m +0 -1
- package/WebDriverAgentTests/IntegrationTests/FBW3CMultiTouchActionsIntegrationTests.m +0 -1
- package/WebDriverAgentTests/IntegrationTests/XCUIApplicationHelperTests.m +8 -8
- package/WebDriverAgentTests/IntegrationTests/XCUIDeviceHelperTests.m +5 -4
- package/WebDriverAgentTests/IntegrationTests/XCUIElementHelperIntegrationTests.m +0 -1
- package/WebDriverAgentTests/UnitTests/Doubles/{FBApplicationDouble.h → XCUIApplicationDouble.h} +1 -1
- package/WebDriverAgentTests/UnitTests/Doubles/{FBApplicationDouble.m → XCUIApplicationDouble.m} +3 -3
- package/WebDriverAgentTests/UnitTests/FBSessionTests.m +3 -3
- package/package.json +1 -1
- package/WebDriverAgent.xcodeproj/project.xcworkspace/xcuserdata/kazu.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/WebDriverAgent.xcodeproj/xcuserdata/kazu.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +0 -1342
- package/WebDriverAgentLib/FBApplication.h +0 -49
- package/WebDriverAgentLib/FBApplication.m +0 -185
|
@@ -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)
|
|
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:(
|
|
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.
|
|
107
|
+
session.testedApplication = nil;
|
|
109
108
|
session.isTestedApplicationExpectedToRun = nil != application && application.running;
|
|
110
109
|
if (application) {
|
|
111
|
-
session.
|
|
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
|
|
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.
|
|
142
|
-
&&
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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
|
-
- (
|
|
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
|
-
|
|
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
|
-
- (
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
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
|
-
|
|
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.
|
|
181
|
+
app.fb_shouldWaitForQuiescence = nil != self.testedApplication && self.shouldAppsWaitForQuiescence;
|
|
184
182
|
} else {
|
|
185
183
|
app.fb_shouldWaitForQuiescence = [shouldWaitForQuiescence boolValue];
|
|
186
184
|
}
|
|
187
|
-
if (app.
|
|
185
|
+
if (!app.running) {
|
|
188
186
|
app.launchArguments = arguments ?: @[];
|
|
189
187
|
app.launchEnvironment = environment ?: @{};
|
|
190
188
|
[app launch];
|
|
191
189
|
} else {
|
|
192
|
-
[app
|
|
190
|
+
[app activate];
|
|
193
191
|
}
|
|
194
|
-
if (
|
|
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
|
-
- (
|
|
198
|
+
- (XCUIApplication *)activateApplicationWithBundleId:(NSString *)bundleIdentifier
|
|
202
199
|
{
|
|
203
|
-
|
|
204
|
-
[app
|
|
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
|
-
|
|
211
|
-
if (
|
|
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.
|
|
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 [
|
|
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<
|
|
53
|
-
for (
|
|
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
|
|
26
|
+
+ (BOOL)waitUntilVisibleForApplication:(XCUIApplication *)app
|
|
27
|
+
timeout:(NSTimeInterval)timeout
|
|
28
|
+
error:(NSError **)error
|
|
29
29
|
{
|
|
30
30
|
BOOL (^isKeyboardVisible)(void) = ^BOOL(void) {
|
|
31
|
-
|
|
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 = [[
|
|
40
|
+
XCUIElement *firstKey = [[keyboard descendantsMatchingType:XCUIElementTypeKey]
|
|
40
41
|
matchingPredicate:keySearchPredicate].allElementsBoundByIndex.firstObject;
|
|
41
42
|
return firstKey.exists && firstKey.hittable;
|
|
42
43
|
};
|
|
@@ -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 =
|
|
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 =
|
|
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 =
|
|
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 = [
|
|
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:
|
|
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:
|
|
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,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)
|
|
23
|
+
@property (nonatomic, strong, readonly) XCUIApplication *springboard;
|
|
26
24
|
|
|
27
25
|
/**
|
|
28
26
|
Launches application and resets side effects of testing like orientation etc.
|
|
@@ -10,12 +10,12 @@
|
|
|
10
10
|
#import <XCTest/XCTest.h>
|
|
11
11
|
|
|
12
12
|
#import "FBAlert.h"
|
|
13
|
-
#import "FBApplication.h"
|
|
14
13
|
#import "FBTestMacros.h"
|
|
15
14
|
#import "FBIntegrationTestCase.h"
|
|
16
15
|
#import "FBConfiguration.h"
|
|
17
16
|
#import "FBMacros.h"
|
|
18
17
|
#import "FBRunLoopSpinner.h"
|
|
18
|
+
#import "XCUIApplication+FBHelpers.h"
|
|
19
19
|
#import "XCUIDevice+FBRotation.h"
|
|
20
20
|
#import "XCUIElement.h"
|
|
21
21
|
#import "XCUIElement+FBIsVisible.h"
|
|
@@ -30,7 +30,7 @@ NSString *const FBTapsCountLabelIdentifier = @"numberOfTapsLabel";
|
|
|
30
30
|
|
|
31
31
|
@interface FBIntegrationTestCase ()
|
|
32
32
|
@property (nonatomic, strong) XCUIApplication *testedApplication;
|
|
33
|
-
@property (nonatomic, strong)
|
|
33
|
+
@property (nonatomic, strong) XCUIApplication *springboard;
|
|
34
34
|
@end
|
|
35
35
|
|
|
36
36
|
@implementation FBIntegrationTestCase
|
|
@@ -46,7 +46,7 @@ NSString *const FBTapsCountLabelIdentifier = @"numberOfTapsLabel";
|
|
|
46
46
|
[FBConfiguration disableApplicationUIInterruptionsHandling];
|
|
47
47
|
[FBConfiguration disableScreenshots];
|
|
48
48
|
self.continueAfterFailure = NO;
|
|
49
|
-
self.springboard =
|
|
49
|
+
self.springboard = XCUIApplication.fb_systemApplication;
|
|
50
50
|
self.testedApplication = [XCUIApplication new];
|
|
51
51
|
}
|
|
52
52
|
|
|
@@ -91,10 +91,10 @@ NSString *const FBTapsCountLabelIdentifier = @"numberOfTapsLabel";
|
|
|
91
91
|
{
|
|
92
92
|
[[XCUIDevice sharedDevice] pressButton:XCUIDeviceButtonHome];
|
|
93
93
|
[self.testedApplication fb_waitUntilStable];
|
|
94
|
-
FBAssertWaitTillBecomesTrue(
|
|
94
|
+
FBAssertWaitTillBecomesTrue(XCUIApplication.fb_systemApplication.icons[@"Safari"].exists);
|
|
95
95
|
[[XCUIDevice sharedDevice] pressButton:XCUIDeviceButtonHome];
|
|
96
96
|
[self.testedApplication fb_waitUntilStable];
|
|
97
|
-
FBAssertWaitTillBecomesTrue(
|
|
97
|
+
FBAssertWaitTillBecomesTrue(XCUIApplication.fb_systemApplication.icons[@"Calendar"].firstMatch.fb_isVisible);
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
- (void)goToSpringBoardExtras
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
#import <XCTest/XCTest.h>
|
|
11
11
|
|
|
12
12
|
#import "FBIntegrationTestCase.h"
|
|
13
|
-
#import "FBApplication.h"
|
|
14
13
|
#import "FBTestMacros.h"
|
|
15
14
|
#import "FBMacros.h"
|
|
16
15
|
#import "FBSession.h"
|
|
@@ -33,7 +32,7 @@ static NSString *const SAFARI_BUNDLE_ID = @"com.apple.mobilesafari";
|
|
|
33
32
|
- (void)setUp
|
|
34
33
|
{
|
|
35
34
|
[super setUp];
|
|
36
|
-
self.session = [FBSession initWithApplication:
|
|
35
|
+
self.session = [FBSession initWithApplication:XCUIApplication.fb_activeApplication];
|
|
37
36
|
[self.session launchApplicationWithBundleId:SAFARI_BUNDLE_ID
|
|
38
37
|
shouldWaitForQuiescence:nil
|
|
39
38
|
arguments:nil
|
|
@@ -10,13 +10,14 @@
|
|
|
10
10
|
#import <XCTest/XCTest.h>
|
|
11
11
|
|
|
12
12
|
#import "FBIntegrationTestCase.h"
|
|
13
|
-
#import "FBApplication.h"
|
|
14
13
|
#import "FBExceptions.h"
|
|
15
14
|
#import "FBMacros.h"
|
|
16
15
|
#import "FBSession.h"
|
|
17
16
|
#import "FBXCodeCompatibility.h"
|
|
18
17
|
#import "FBTestMacros.h"
|
|
19
18
|
#import "FBUnattachedAppLauncher.h"
|
|
19
|
+
#import "XCUIApplication+FBHelpers.h"
|
|
20
|
+
#import "XCUIApplication.h"
|
|
20
21
|
|
|
21
22
|
@interface FBSession (Tests)
|
|
22
23
|
|
|
@@ -35,7 +36,7 @@ static NSString *const SETTINGS_BUNDLE_ID = @"com.apple.Preferences";
|
|
|
35
36
|
{
|
|
36
37
|
[super setUp];
|
|
37
38
|
[self launchApplication];
|
|
38
|
-
|
|
39
|
+
XCUIApplication *app = [[XCUIApplication alloc] initWithBundleIdentifier:self.testedApplication.bundleID];
|
|
39
40
|
self.session = [FBSession initWithApplication:app];
|
|
40
41
|
}
|
|
41
42
|
|
|
@@ -47,7 +48,7 @@ static NSString *const SETTINGS_BUNDLE_ID = @"com.apple.Preferences";
|
|
|
47
48
|
|
|
48
49
|
- (void)testSettingsAppCanBeOpenedInScopeOfTheCurrentSession
|
|
49
50
|
{
|
|
50
|
-
|
|
51
|
+
XCUIApplication *testedApp = XCUIApplication.fb_activeApplication;
|
|
51
52
|
[self.session launchApplicationWithBundleId:SETTINGS_BUNDLE_ID
|
|
52
53
|
shouldWaitForQuiescence:nil
|
|
53
54
|
arguments:nil
|
|
@@ -61,7 +62,7 @@ static NSString *const SETTINGS_BUNDLE_ID = @"com.apple.Preferences";
|
|
|
61
62
|
|
|
62
63
|
- (void)testSettingsAppCanBeReopenedInScopeOfTheCurrentSession
|
|
63
64
|
{
|
|
64
|
-
|
|
65
|
+
XCUIApplication *systemApp = self.springboard;
|
|
65
66
|
[self.session launchApplicationWithBundleId:SETTINGS_BUNDLE_ID
|
|
66
67
|
shouldWaitForQuiescence:nil
|
|
67
68
|
arguments:nil
|
|
@@ -78,7 +79,7 @@ static NSString *const SETTINGS_BUNDLE_ID = @"com.apple.Preferences";
|
|
|
78
79
|
|
|
79
80
|
- (void)testMainAppCanBeReactivatedInScopeOfTheCurrentSession
|
|
80
81
|
{
|
|
81
|
-
|
|
82
|
+
XCUIApplication *testedApp = XCUIApplication.fb_activeApplication;
|
|
82
83
|
[self.session launchApplicationWithBundleId:SETTINGS_BUNDLE_ID
|
|
83
84
|
shouldWaitForQuiescence:nil
|
|
84
85
|
arguments:nil
|
|
@@ -90,8 +91,8 @@ static NSString *const SETTINGS_BUNDLE_ID = @"com.apple.Preferences";
|
|
|
90
91
|
|
|
91
92
|
- (void)testMainAppCanBeRestartedInScopeOfTheCurrentSession
|
|
92
93
|
{
|
|
93
|
-
|
|
94
|
-
|
|
94
|
+
XCUIApplication *systemApp = self.springboard;
|
|
95
|
+
XCUIApplication *testedApp = [[XCUIApplication alloc] initWithBundleIdentifier:self.testedApplication.bundleID];
|
|
95
96
|
[self.session terminateApplicationWithBundleId:testedApp.bundleID];
|
|
96
97
|
FBAssertWaitTillBecomesTrue([self.session.activeApplication.bundleID isEqualToString:systemApp.bundleID]);
|
|
97
98
|
[self.session launchApplicationWithBundleId:testedApp.bundleID
|
|
@@ -105,12 +106,12 @@ static NSString *const SETTINGS_BUNDLE_ID = @"com.apple.Preferences";
|
|
|
105
106
|
{
|
|
106
107
|
[FBUnattachedAppLauncher launchAppWithBundleId:SETTINGS_BUNDLE_ID];
|
|
107
108
|
[self.session kill];
|
|
108
|
-
XCTAssertEqualObjects(SETTINGS_BUNDLE_ID,
|
|
109
|
+
XCTAssertEqualObjects(SETTINGS_BUNDLE_ID, XCUIApplication.fb_activeApplication.bundleID);
|
|
109
110
|
}
|
|
110
111
|
|
|
111
112
|
- (void)testAppWithInvalidBundleIDCannotBeStarted
|
|
112
113
|
{
|
|
113
|
-
|
|
114
|
+
XCUIApplication *testedApp = [[XCUIApplication alloc] initWithBundleIdentifier:@"yolo"];
|
|
114
115
|
@try {
|
|
115
116
|
[testedApp launch];
|
|
116
117
|
XCTFail(@"An exception is expected to be thrown");
|
|
@@ -121,7 +122,7 @@ static NSString *const SETTINGS_BUNDLE_ID = @"com.apple.Preferences";
|
|
|
121
122
|
|
|
122
123
|
- (void)testAppWithInvalidBundleIDCannotBeActivated
|
|
123
124
|
{
|
|
124
|
-
|
|
125
|
+
XCUIApplication *testedApp = [[XCUIApplication alloc] initWithBundleIdentifier:@"yolo"];
|
|
125
126
|
@try {
|
|
126
127
|
[testedApp activate];
|
|
127
128
|
XCTFail(@"An exception is expected to be thrown");
|