appium-webdriveragent 4.1.7 → 4.2.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.
@@ -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,15 @@ 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
+
123
138
  @end
124
139
 
125
140
  NS_ASSUME_NONNULL_END
@@ -309,4 +309,21 @@ 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
+
312
329
  @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
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appium-webdriveragent",
3
- "version": "4.1.7",
3
+ "version": "4.2.0",
4
4
  "description": "Package bundling WebDriverAgent",
5
5
  "main": "build/index.js",
6
6
  "scripts": {