appium-webdriveragent 5.1.2 → 5.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.
- package/CHANGELOG.md +14 -0
- package/PrivateHeaders/XCTest/XCTRunnerDaemonSession.h +7 -0
- package/WebDriverAgentLib/FBApplication.h +0 -10
- package/WebDriverAgentLib/FBApplication.m +0 -36
- package/WebDriverAgentLib/Utilities/FBXCTestDaemonsProxy.m +58 -23
- package/WebDriverAgentTests/IntegrationTests/FBSessionIntegrationTests.m +7 -13
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [5.1.4](https://github.com/appium/WebDriverAgent/compare/v5.1.3...v5.1.4) (2023-05-16)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* Prevent freeze on launch/activate of a missing app ([#706](https://github.com/appium/WebDriverAgent/issues/706)) ([c4976e3](https://github.com/appium/WebDriverAgent/commit/c4976e3e99afa4d471bd39c3dccfc7d9f58d8bfc))
|
|
7
|
+
|
|
8
|
+
## [5.1.3](https://github.com/appium/WebDriverAgent/compare/v5.1.2...v5.1.3) (2023-05-16)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* Revert "fix: Assert app is installed before launching or activating it ([#704](https://github.com/appium/WebDriverAgent/issues/704))" ([#705](https://github.com/appium/WebDriverAgent/issues/705)) ([00baeb2](https://github.com/appium/WebDriverAgent/commit/00baeb2045b9aac98d27fe2e96cedce0dde5e8be))
|
|
14
|
+
|
|
1
15
|
## [5.1.2](https://github.com/appium/WebDriverAgent/compare/v5.1.1...v5.1.2) (2023-05-15)
|
|
2
16
|
|
|
3
17
|
|
|
@@ -80,4 +80,11 @@
|
|
|
80
80
|
@property(readonly) _Bool supportsLocationSimulation;
|
|
81
81
|
#endif
|
|
82
82
|
|
|
83
|
+
// Since Xcode 10.2
|
|
84
|
+
- (void)launchApplicationWithPath:(NSString *)arg1
|
|
85
|
+
bundleID:(NSString *)arg2
|
|
86
|
+
arguments:(NSArray *)arg3
|
|
87
|
+
environment:(NSDictionary *)arg4
|
|
88
|
+
completion:(void (^)(_Bool, NSError *))arg5;
|
|
89
|
+
|
|
83
90
|
@end
|
|
@@ -44,16 +44,6 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
44
44
|
*/
|
|
45
45
|
+ (BOOL)fb_switchToSystemApplicationWithError:(NSError **)error;
|
|
46
46
|
|
|
47
|
-
/**
|
|
48
|
-
Returns the bundle indentifier of the system app (ususally Springboard)
|
|
49
|
-
*/
|
|
50
|
-
+ (NSString *)fb_systemApplicationBundleID;
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
Checks if the app is installed on the device under test.
|
|
54
|
-
*/
|
|
55
|
-
- (BOOL)fb_isInstalled;
|
|
56
|
-
|
|
57
47
|
@end
|
|
58
48
|
|
|
59
49
|
NS_ASSUME_NONNULL_END
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
|
|
10
10
|
#import "FBApplication.h"
|
|
11
11
|
|
|
12
|
-
#import "FBExceptions.h"
|
|
13
12
|
#import "FBXCAccessibilityElement.h"
|
|
14
13
|
#import "FBLogger.h"
|
|
15
14
|
#import "FBRunLoopSpinner.h"
|
|
@@ -17,7 +16,6 @@
|
|
|
17
16
|
#import "FBActiveAppDetectionPoint.h"
|
|
18
17
|
#import "FBXCodeCompatibility.h"
|
|
19
18
|
#import "FBXCTestDaemonsProxy.h"
|
|
20
|
-
#import "LSApplicationWorkspace.h"
|
|
21
19
|
#import "XCUIApplication.h"
|
|
22
20
|
#import "XCUIApplication+FBHelpers.h"
|
|
23
21
|
#import "XCUIApplicationImpl.h"
|
|
@@ -135,16 +133,6 @@ static const NSTimeInterval APP_STATE_CHANGE_TIMEOUT = 5.0;
|
|
|
135
133
|
[[FBXCAXClientProxy.sharedClient systemApplication] processIdentifier]];
|
|
136
134
|
}
|
|
137
135
|
|
|
138
|
-
+ (NSString *)fb_systemApplicationBundleID
|
|
139
|
-
{
|
|
140
|
-
static dispatch_once_t onceToken;
|
|
141
|
-
static NSString *systemAppBundleID;
|
|
142
|
-
dispatch_once(&onceToken, ^{
|
|
143
|
-
systemAppBundleID = [[self.class fb_systemApplication] bundleID];
|
|
144
|
-
});
|
|
145
|
-
return systemAppBundleID;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
136
|
+ (instancetype)applicationWithPID:(pid_t)processID
|
|
149
137
|
{
|
|
150
138
|
if ([NSProcessInfo processInfo].processIdentifier == processID) {
|
|
@@ -153,33 +141,14 @@ static const NSTimeInterval APP_STATE_CHANGE_TIMEOUT = 5.0;
|
|
|
153
141
|
return (FBApplication *)[FBXCAXClientProxy.sharedClient monitoredApplicationWithProcessIdentifier:processID];
|
|
154
142
|
}
|
|
155
143
|
|
|
156
|
-
/**
|
|
157
|
-
https://github.com/appium/WebDriverAgent/issues/702
|
|
158
|
-
*/
|
|
159
|
-
- (void)fb_assertInstalledByAction:(NSString *)action
|
|
160
|
-
{
|
|
161
|
-
if (![self.bundleID isEqualToString:[self.class fb_systemApplicationBundleID]] && !self.fb_isInstalled) {
|
|
162
|
-
NSString *message = [NSString stringWithFormat:@"The application '%@' cannot be %@ because it is not installed on the device under test",
|
|
163
|
-
self.bundleID, action];
|
|
164
|
-
[[NSException exceptionWithName:FBApplicationMissingException reason:message userInfo:nil] raise];
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
144
|
- (void)launch
|
|
169
145
|
{
|
|
170
|
-
[self fb_assertInstalledByAction:@"launched"];
|
|
171
146
|
[super launch];
|
|
172
147
|
if (![self fb_waitForAppElement:APP_STATE_CHANGE_TIMEOUT]) {
|
|
173
148
|
[FBLogger logFmt:@"The application '%@' is not running in foreground after %.2f seconds", self.bundleID, APP_STATE_CHANGE_TIMEOUT];
|
|
174
149
|
}
|
|
175
150
|
}
|
|
176
151
|
|
|
177
|
-
- (void)activate
|
|
178
|
-
{
|
|
179
|
-
[self fb_assertInstalledByAction:@"activated"];
|
|
180
|
-
[super activate];
|
|
181
|
-
}
|
|
182
|
-
|
|
183
152
|
- (void)terminate
|
|
184
153
|
{
|
|
185
154
|
[super terminate];
|
|
@@ -212,9 +181,4 @@ static const NSTimeInterval APP_STATE_CHANGE_TIMEOUT = 5.0;
|
|
|
212
181
|
error:error];
|
|
213
182
|
}
|
|
214
183
|
|
|
215
|
-
- (BOOL)fb_isInstalled
|
|
216
|
-
{
|
|
217
|
-
return [[LSApplicationWorkspace defaultWorkspace] applicationIsInstalled:self.bundleID];
|
|
218
|
-
}
|
|
219
|
-
|
|
220
184
|
@end
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
#import "FBConfiguration.h"
|
|
15
15
|
#import "FBErrorBuilder.h"
|
|
16
|
+
#import "FBExceptions.h"
|
|
16
17
|
#import "FBLogger.h"
|
|
17
18
|
#import "FBRunLoopSpinner.h"
|
|
18
19
|
#import "XCTestDriver.h"
|
|
@@ -20,23 +21,61 @@
|
|
|
20
21
|
#import "XCUIApplication.h"
|
|
21
22
|
#import "XCUIDevice.h"
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
#define LAUNCH_APP_TIMEOUT_SEC 300
|
|
25
|
+
|
|
26
|
+
static void (*originalLaunchAppMethod)(id, SEL, NSString*, NSString*, NSArray*, NSDictionary*, void (^)(_Bool, NSError *));
|
|
24
27
|
|
|
25
|
-
static
|
|
26
|
-
|
|
28
|
+
static void swizzledLaunchApp(id self, SEL _cmd, NSString *path, NSString *bundleID,
|
|
29
|
+
NSArray *arguments, NSDictionary *environment,
|
|
30
|
+
void (^reply)(_Bool, NSError *))
|
|
31
|
+
{
|
|
32
|
+
__block BOOL isSuccessful;
|
|
33
|
+
__block NSError *error;
|
|
34
|
+
dispatch_semaphore_t sem = dispatch_semaphore_create(0);
|
|
35
|
+
originalLaunchAppMethod(self, _cmd, path, bundleID, arguments, environment, ^(BOOL passed, NSError *innerError) {
|
|
36
|
+
isSuccessful = passed;
|
|
37
|
+
error = innerError;
|
|
38
|
+
dispatch_semaphore_signal(sem);
|
|
39
|
+
});
|
|
40
|
+
int64_t timeoutNs = (int64_t)(LAUNCH_APP_TIMEOUT_SEC * NSEC_PER_SEC);
|
|
41
|
+
if (0 != dispatch_semaphore_wait(sem, dispatch_time(DISPATCH_TIME_NOW, timeoutNs))) {
|
|
42
|
+
NSString *message = [NSString stringWithFormat:@"The application '%@' cannot be launched within %d seconds timeout",
|
|
43
|
+
bundleID ?: path, LAUNCH_APP_TIMEOUT_SEC];
|
|
44
|
+
@throw [NSException exceptionWithName:FBTimeoutException reason:message userInfo:nil];
|
|
45
|
+
}
|
|
46
|
+
if (!isSuccessful || nil != error) {
|
|
47
|
+
[FBLogger logFmt:@"%@", error.description];
|
|
48
|
+
NSString *message = error.description ?: [NSString stringWithFormat:@"The application '%@' is not installed on the device under test",
|
|
49
|
+
bundleID ?: path];
|
|
50
|
+
@throw [NSException exceptionWithName:FBApplicationMissingException reason:message userInfo:nil];
|
|
51
|
+
}
|
|
52
|
+
reply(isSuccessful, error);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@implementation FBXCTestDaemonsProxy
|
|
27
56
|
|
|
28
57
|
#pragma clang diagnostic push
|
|
29
58
|
#pragma clang diagnostic ignored "-Wobjc-load-method"
|
|
30
59
|
|
|
31
60
|
+ (void)load
|
|
32
61
|
{
|
|
33
|
-
|
|
34
|
-
FBXCTRunnerDaemonSessionClass = objc_lookUpClass("XCTRunnerDaemonSession");
|
|
35
|
-
});
|
|
62
|
+
[self.class swizzleLaunchApp];
|
|
36
63
|
}
|
|
37
64
|
|
|
38
65
|
#pragma clang diagnostic pop
|
|
39
66
|
|
|
67
|
+
+ (void)swizzleLaunchApp {
|
|
68
|
+
Method original = class_getInstanceMethod([XCTRunnerDaemonSession class],
|
|
69
|
+
@selector(launchApplicationWithPath:bundleID:arguments:environment:completion:));
|
|
70
|
+
if (original == nil) {
|
|
71
|
+
[FBLogger log:@"Could not find method -[XCTRunnerDaemonSession launchApplicationWithPath:]"];
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
// Workaround for https://github.com/appium/WebDriverAgent/issues/702
|
|
75
|
+
originalLaunchAppMethod = (void(*)(id, SEL, NSString*, NSString*, NSArray*, NSDictionary*, void (^)(_Bool, NSError *))) method_getImplementation(original);
|
|
76
|
+
method_setImplementation(original, (IMP)swizzledLaunchApp);
|
|
77
|
+
}
|
|
78
|
+
|
|
40
79
|
+ (id<XCTestManager_ManagerInterface>)testRunnerProxy
|
|
41
80
|
{
|
|
42
81
|
static id<XCTestManager_ManagerInterface> proxy = nil;
|
|
@@ -56,7 +95,7 @@ static dispatch_once_t onceTestRunnerDaemonClass;
|
|
|
56
95
|
|
|
57
96
|
+ (id<XCTestManager_ManagerInterface>)retrieveTestRunnerProxy
|
|
58
97
|
{
|
|
59
|
-
return ((XCTRunnerDaemonSession *)[
|
|
98
|
+
return ((XCTRunnerDaemonSession *)[XCTRunnerDaemonSession sharedSession]).daemonProxy;
|
|
60
99
|
}
|
|
61
100
|
|
|
62
101
|
+ (BOOL)synthesizeEventWithRecord:(XCSynthesizedEventRecord *)record error:(NSError *__autoreleasing*)error
|
|
@@ -70,24 +109,20 @@ static dispatch_once_t onceTestRunnerDaemonClass;
|
|
|
70
109
|
didSucceed = (invokeError == nil);
|
|
71
110
|
completion();
|
|
72
111
|
};
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
[[XCUIDevice.sharedDevice eventSynthesizer] synthesizeEvent:record completion:(id)^(BOOL result, NSError *invokeError) {
|
|
81
|
-
handlerBlock(record, invokeError);
|
|
82
|
-
}];
|
|
83
|
-
}
|
|
112
|
+
|
|
113
|
+
XCEventGeneratorHandler handlerBlock = ^(XCSynthesizedEventRecord *innerRecord, NSError *invokeError) {
|
|
114
|
+
errorHandler(invokeError);
|
|
115
|
+
};
|
|
116
|
+
[[XCUIDevice.sharedDevice eventSynthesizer] synthesizeEvent:record completion:(id)^(BOOL result, NSError *invokeError) {
|
|
117
|
+
handlerBlock(record, invokeError);
|
|
118
|
+
}];
|
|
84
119
|
}];
|
|
85
120
|
return didSucceed;
|
|
86
121
|
}
|
|
87
122
|
|
|
88
123
|
+ (BOOL)openURL:(NSURL *)url usingApplication:(NSString *)bundleId error:(NSError *__autoreleasing*)error
|
|
89
124
|
{
|
|
90
|
-
XCTRunnerDaemonSession *session = [
|
|
125
|
+
XCTRunnerDaemonSession *session = [XCTRunnerDaemonSession sharedSession];
|
|
91
126
|
if (![session respondsToSelector:@selector(openURL:usingApplication:completion:)]) {
|
|
92
127
|
if (error) {
|
|
93
128
|
[[[FBErrorBuilder builder]
|
|
@@ -112,7 +147,7 @@ static dispatch_once_t onceTestRunnerDaemonClass;
|
|
|
112
147
|
|
|
113
148
|
+ (BOOL)openDefaultApplicationForURL:(NSURL *)url error:(NSError *__autoreleasing*)error
|
|
114
149
|
{
|
|
115
|
-
XCTRunnerDaemonSession *session = [
|
|
150
|
+
XCTRunnerDaemonSession *session = [XCTRunnerDaemonSession sharedSession];
|
|
116
151
|
if (![session respondsToSelector:@selector(openDefaultApplicationForURL:completion:)]) {
|
|
117
152
|
if (error) {
|
|
118
153
|
[[[FBErrorBuilder builder]
|
|
@@ -138,7 +173,7 @@ static dispatch_once_t onceTestRunnerDaemonClass;
|
|
|
138
173
|
#if !TARGET_OS_TV
|
|
139
174
|
+ (BOOL)setSimulatedLocation:(CLLocation *)location error:(NSError *__autoreleasing*)error
|
|
140
175
|
{
|
|
141
|
-
XCTRunnerDaemonSession *session = [
|
|
176
|
+
XCTRunnerDaemonSession *session = [XCTRunnerDaemonSession sharedSession];
|
|
142
177
|
if (![session respondsToSelector:@selector(setSimulatedLocation:completion:)]) {
|
|
143
178
|
if (error) {
|
|
144
179
|
[[[FBErrorBuilder builder]
|
|
@@ -171,7 +206,7 @@ static dispatch_once_t onceTestRunnerDaemonClass;
|
|
|
171
206
|
|
|
172
207
|
+ (nullable CLLocation *)getSimulatedLocation:(NSError *__autoreleasing*)error;
|
|
173
208
|
{
|
|
174
|
-
XCTRunnerDaemonSession *session = [
|
|
209
|
+
XCTRunnerDaemonSession *session = [XCTRunnerDaemonSession sharedSession];
|
|
175
210
|
if (![session respondsToSelector:@selector(getSimulatedLocationWithReply:)]) {
|
|
176
211
|
if (error) {
|
|
177
212
|
[[[FBErrorBuilder builder]
|
|
@@ -206,7 +241,7 @@ static dispatch_once_t onceTestRunnerDaemonClass;
|
|
|
206
241
|
|
|
207
242
|
+ (BOOL)clearSimulatedLocation:(NSError *__autoreleasing*)error
|
|
208
243
|
{
|
|
209
|
-
XCTRunnerDaemonSession *session = [
|
|
244
|
+
XCTRunnerDaemonSession *session = [XCTRunnerDaemonSession sharedSession];
|
|
210
245
|
if (![session respondsToSelector:@selector(clearSimulatedLocationWithReply:)]) {
|
|
211
246
|
if (error) {
|
|
212
247
|
[[[FBErrorBuilder builder]
|
|
@@ -101,6 +101,13 @@ static NSString *const SETTINGS_BUNDLE_ID = @"com.apple.Preferences";
|
|
|
101
101
|
FBAssertWaitTillBecomesTrue([self.session.activeApplication.bundleID isEqualToString:testedApp.bundleID]);
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
+
- (void)testLaunchUnattachedApp
|
|
105
|
+
{
|
|
106
|
+
[FBUnattachedAppLauncher launchAppWithBundleId:SETTINGS_BUNDLE_ID];
|
|
107
|
+
[self.session kill];
|
|
108
|
+
XCTAssertEqualObjects(SETTINGS_BUNDLE_ID, FBApplication.fb_activeApplication.bundleID);
|
|
109
|
+
}
|
|
110
|
+
|
|
104
111
|
- (void)testAppWithInvalidBundleIDCannotBeStarted
|
|
105
112
|
{
|
|
106
113
|
FBApplication *testedApp = [[FBApplication alloc] initWithBundleIdentifier:@"yolo"];
|
|
@@ -123,17 +130,4 @@ static NSString *const SETTINGS_BUNDLE_ID = @"com.apple.Preferences";
|
|
|
123
130
|
}
|
|
124
131
|
}
|
|
125
132
|
|
|
126
|
-
- (void)testAppWithInvalidBundleIDCannotBeTerminated
|
|
127
|
-
{
|
|
128
|
-
FBApplication *testedApp = [[FBApplication alloc] initWithBundleIdentifier:@"yolo"];
|
|
129
|
-
[testedApp terminate];
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
- (void)testLaunchUnattachedApp
|
|
133
|
-
{
|
|
134
|
-
[FBUnattachedAppLauncher launchAppWithBundleId:SETTINGS_BUNDLE_ID];
|
|
135
|
-
[self.session kill];
|
|
136
|
-
XCTAssertEqualObjects(SETTINGS_BUNDLE_ID, FBApplication.fb_activeApplication.bundleID);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
133
|
@end
|