appium-webdriveragent 4.1.7 → 4.3.1
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/PrivateHeaders/XCTest/XCUIDevice.h +8 -1
- package/WebDriverAgentLib/Categories/XCUIDevice+FBHelpers.h +22 -0
- package/WebDriverAgentLib/Categories/XCUIDevice+FBHelpers.m +24 -0
- package/WebDriverAgentLib/Commands/FBCustomCommands.m +40 -3
- package/WebDriverAgentLib/Utilities/FBScreenshot.m +2 -1
- package/WebDriverAgentRunner-Runner.app.zip +0 -0
- package/WebDriverAgentTests/IntegrationTests/XCUIDeviceHelperTests.m +10 -0
- package/package.json +1 -1
|
@@ -11,9 +11,16 @@
|
|
|
11
11
|
// Since Xcode 10.2
|
|
12
12
|
@property (readonly) id accessibilityInterface; // implements XCUIAccessibilityInterface
|
|
13
13
|
@property (readonly) id eventSynthesizer; // implements XCUIEventSynthesizing
|
|
14
|
-
@property(readonly) id screenDataSource; // @synthesize screenDataSource=_screenDataSource;
|
|
14
|
+
@property (readonly) id screenDataSource; // @synthesize screenDataSource=_screenDataSource;
|
|
15
|
+
|
|
15
16
|
- (_Bool)performDeviceEvent:(id)arg1 error:(id *)arg2;
|
|
16
17
|
|
|
18
|
+
// Since Xcode 13
|
|
19
|
+
// 1 - Light
|
|
20
|
+
// 2 - Dark
|
|
21
|
+
- (void)setAppearanceMode:(long long)arg1;
|
|
22
|
+
- (long long)appearanceMode;
|
|
23
|
+
|
|
17
24
|
- (void)pressLockButton;
|
|
18
25
|
- (void)holdHomeButtonForDuration:(double)arg1;
|
|
19
26
|
- (void)_silentPressButton:(long long)arg1;
|
|
@@ -11,6 +11,12 @@
|
|
|
11
11
|
|
|
12
12
|
NS_ASSUME_NONNULL_BEGIN
|
|
13
13
|
|
|
14
|
+
typedef NS_ENUM(NSUInteger, FBUIInterfaceAppearance) {
|
|
15
|
+
FBUIInterfaceAppearanceUnspecified,
|
|
16
|
+
FBUIInterfaceAppearanceLight,
|
|
17
|
+
FBUIInterfaceAppearanceDark
|
|
18
|
+
};
|
|
19
|
+
|
|
14
20
|
@interface XCUIDevice (FBHelpers)
|
|
15
21
|
|
|
16
22
|
/**
|
|
@@ -120,6 +126,22 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
120
126
|
duration:(NSTimeInterval)duration
|
|
121
127
|
error:(NSError **)error;
|
|
122
128
|
|
|
129
|
+
/**
|
|
130
|
+
Allows to set device appearance
|
|
131
|
+
|
|
132
|
+
@param appearance The desired appearance value
|
|
133
|
+
@param error If there is an error, upon return contains an NSError object that describes the problem.
|
|
134
|
+
@return YES if the appearance has been successfully set
|
|
135
|
+
*/
|
|
136
|
+
- (BOOL)fb_setAppearance:(FBUIInterfaceAppearance)appearance error:(NSError **)error;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
Get current appearance prefefence.
|
|
140
|
+
|
|
141
|
+
@return 0 (automatic), 1 (light) or 2 (dark), or nil
|
|
142
|
+
*/
|
|
143
|
+
- (nullable NSNumber *)fb_getAppearance;
|
|
144
|
+
|
|
123
145
|
@end
|
|
124
146
|
|
|
125
147
|
NS_ASSUME_NONNULL_END
|
|
@@ -309,4 +309,28 @@ static bool fb_isLocked;
|
|
|
309
309
|
return [self performDeviceEvent:event error:error];
|
|
310
310
|
}
|
|
311
311
|
|
|
312
|
+
- (BOOL)fb_setAppearance:(FBUIInterfaceAppearance)appearance error:(NSError **)error
|
|
313
|
+
{
|
|
314
|
+
SEL selector = NSSelectorFromString(@"setAppearanceMode:");
|
|
315
|
+
if (nil != selector && [self respondsToSelector:selector]) {
|
|
316
|
+
NSMethodSignature *signature = [self methodSignatureForSelector:selector];
|
|
317
|
+
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
|
|
318
|
+
[invocation setSelector:selector];
|
|
319
|
+
[invocation setTarget:self];
|
|
320
|
+
[invocation setArgument:&appearance atIndex:2];
|
|
321
|
+
[invocation invoke];
|
|
322
|
+
return YES;
|
|
323
|
+
}
|
|
324
|
+
return [[[FBErrorBuilder builder]
|
|
325
|
+
withDescriptionFormat:@"Current Xcode SDK does not support appearance changing"]
|
|
326
|
+
buildError:error];
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
- (NSNumber *)fb_getAppearance
|
|
330
|
+
{
|
|
331
|
+
return [self respondsToSelector:@selector(appearanceMode)]
|
|
332
|
+
? [NSNumber numberWithLongLong:[self appearanceMode]]
|
|
333
|
+
: nil;
|
|
334
|
+
}
|
|
335
|
+
|
|
312
336
|
@end
|
|
@@ -63,6 +63,7 @@
|
|
|
63
63
|
[[FBRoute GET:@"/wda/device/info"] respondWithTarget:self action:@selector(handleGetDeviceInfo:)],
|
|
64
64
|
[[FBRoute POST:@"/wda/resetAppAuth"] respondWithTarget:self action:@selector(handleResetAppAuth:)],
|
|
65
65
|
[[FBRoute GET:@"/wda/device/info"].withoutSession respondWithTarget:self action:@selector(handleGetDeviceInfo:)],
|
|
66
|
+
[[FBRoute POST:@"/wda/device/appearance"].withoutSession respondWithTarget:self action:@selector(handleSetDeviceAppearance:)],
|
|
66
67
|
[[FBRoute GET:@"/wda/device/location"] respondWithTarget:self action:@selector(handleGetLocation:)],
|
|
67
68
|
[[FBRoute GET:@"/wda/device/location"].withoutSession respondWithTarget:self action:@selector(handleGetLocation:)],
|
|
68
69
|
[[FBRoute OPTIONS:@"/*"].withoutSession respondWithTarget:self action:@selector(handlePingCommand:)],
|
|
@@ -369,6 +370,25 @@
|
|
|
369
370
|
return FBResponseWithOK();
|
|
370
371
|
}
|
|
371
372
|
|
|
373
|
+
+ (id<FBResponsePayload>)handleSetDeviceAppearance:(FBRouteRequest *)request
|
|
374
|
+
{
|
|
375
|
+
NSString *name = [request.arguments[@"name"] lowercaseString];
|
|
376
|
+
if (nil == name || !([name isEqualToString:@"light"] || [name isEqualToString:@"dark"])) {
|
|
377
|
+
NSString *message = @"The appearance name must be either 'light' or 'dark'";
|
|
378
|
+
return FBResponseWithStatus([FBCommandStatus invalidArgumentErrorWithMessage:message traceback:nil]);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
FBUIInterfaceAppearance appearance = [name isEqualToString:@"light"]
|
|
382
|
+
? FBUIInterfaceAppearanceLight
|
|
383
|
+
: FBUIInterfaceAppearanceDark;
|
|
384
|
+
NSError *error;
|
|
385
|
+
if (![XCUIDevice.sharedDevice fb_setAppearance:appearance error:&error]) {
|
|
386
|
+
return FBResponseWithStatus([FBCommandStatus unknownErrorWithMessage:error.description
|
|
387
|
+
traceback:nil]);
|
|
388
|
+
}
|
|
389
|
+
return FBResponseWithOK();
|
|
390
|
+
}
|
|
391
|
+
|
|
372
392
|
+ (id<FBResponsePayload>)handleGetDeviceInfo:(FBRouteRequest *)request
|
|
373
393
|
{
|
|
374
394
|
// Returns locale like ja_EN and zh-Hant_US. The format depends on OS
|
|
@@ -406,6 +426,16 @@
|
|
|
406
426
|
*/
|
|
407
427
|
+ (NSString *)userInterfaceStyle
|
|
408
428
|
{
|
|
429
|
+
|
|
430
|
+
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"15.0")) {
|
|
431
|
+
// Only iOS 15+ simulators/devices return correct data while
|
|
432
|
+
// the api itself works in iOS 13 and 14 that has style preference.
|
|
433
|
+
NSNumber *appearance = [XCUIDevice.sharedDevice fb_getAppearance];
|
|
434
|
+
if (appearance != nil) {
|
|
435
|
+
return [self getAppearanceName:appearance];
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
409
439
|
static id userInterfaceStyle = nil;
|
|
410
440
|
static dispatch_once_t styleOnceToken;
|
|
411
441
|
dispatch_once(&styleOnceToken, ^{
|
|
@@ -421,10 +451,17 @@
|
|
|
421
451
|
return @"unsupported";
|
|
422
452
|
}
|
|
423
453
|
|
|
424
|
-
|
|
425
|
-
|
|
454
|
+
return [self getAppearanceName:userInterfaceStyle];
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
+ (NSString *)getAppearanceName:(NSNumber *)appearance
|
|
458
|
+
{
|
|
459
|
+
switch ([appearance longLongValue]) {
|
|
460
|
+
case FBUIInterfaceAppearanceUnspecified:
|
|
461
|
+
return @"automatic";
|
|
462
|
+
case FBUIInterfaceAppearanceLight:
|
|
426
463
|
return @"light";
|
|
427
|
-
case
|
|
464
|
+
case FBUIInterfaceAppearanceDark:
|
|
428
465
|
return @"dark";
|
|
429
466
|
default:
|
|
430
467
|
return @"unknown";
|
|
@@ -212,7 +212,8 @@ NSString *formatTimeInterval(NSTimeInterval interval) {
|
|
|
212
212
|
dispatch_once(&shouldUseSRApi, ^{
|
|
213
213
|
if ([proxy respondsToSelector:@selector(_XCT_requestScreenshot:withReply:)]) {
|
|
214
214
|
#if TARGET_OS_SIMULATOR
|
|
215
|
-
|
|
215
|
+
// Required to support simulators running iOS 14.4 and below with Xcode 12.5 and above due to unsupported API on the simulator side.
|
|
216
|
+
result = SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"14.5");
|
|
216
217
|
#else
|
|
217
218
|
result = SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"15.0");
|
|
218
219
|
#endif
|
|
Binary file
|
|
@@ -156,4 +156,14 @@
|
|
|
156
156
|
XCTAssertNil(error);
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
+
- (void)testAppearance
|
|
160
|
+
{
|
|
161
|
+
if (SYSTEM_VERSION_LESS_THAN(@"15.0")) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
NSError *error;
|
|
165
|
+
XCTAssertTrue([XCUIDevice.sharedDevice fb_setAppearance:FBUIInterfaceAppearanceDark error:&error]);
|
|
166
|
+
XCTAssertNil(error);
|
|
167
|
+
}
|
|
168
|
+
|
|
159
169
|
@end
|