18
18
19
19
import com .google .common .collect .ImmutableMap ;
20
20
21
+ import io .appium .java_client .screenrecording .BaseStartScreenRecordingOptions ;
22
+ import io .appium .java_client .screenrecording .BaseStopScreenRecordingOptions ;
21
23
import org .apache .commons .lang3 .StringUtils ;
22
24
import org .openqa .selenium .remote .CommandInfo ;
23
25
import org .openqa .selenium .remote .http .HttpMethod ;
@@ -53,6 +55,8 @@ public class MobileCommand {
53
55
protected static final String GET_PERFORMANCE_DATA ;
54
56
protected static final String GET_SUPPORTED_PERFORMANCE_DATA_TYPES ;
55
57
58
+ public static final String START_RECORDING_SCREEN ;
59
+ public static final String STOP_RECORDING_SCREEN ;
56
60
57
61
protected static final String HIDE_KEYBOARD ;
58
62
protected static final String LOCK ;
@@ -82,7 +86,7 @@ public class MobileCommand {
82
86
protected static final String SET_SETTINGS ;
83
87
protected static final String GET_CURRENT_PACKAGE ;
84
88
85
- public static final Map <String , CommandInfo > commandRepository ;
89
+ public static final Map <String , CommandInfo > commandRepository ;
86
90
87
91
static {
88
92
RESET = "reset" ;
@@ -104,6 +108,9 @@ public class MobileCommand {
104
108
GET_PERFORMANCE_DATA = "getPerformanceData" ;
105
109
GET_SUPPORTED_PERFORMANCE_DATA_TYPES = "getSuppportedPerformanceDataTypes" ;
106
110
111
+ START_RECORDING_SCREEN = "startRecordingScreen" ;
112
+ STOP_RECORDING_SCREEN = "stopRecordingScreen" ;
113
+
107
114
HIDE_KEYBOARD = "hideKeyboard" ;
108
115
LOCK = "lock" ;
109
116
SHAKE = "shake" ;
@@ -150,44 +157,47 @@ public class MobileCommand {
150
157
commandRepository .put (GET_SETTINGS , getC ("/session/:sessionId/appium/settings" ));
151
158
commandRepository .put (SET_SETTINGS , postC ("/session/:sessionId/appium/settings" ));
152
159
commandRepository .put (GET_DEVICE_TIME , getC ("/session/:sessionId/appium/device/system_time" ));
153
- commandRepository .put (GET_SESSION ,getC ("/session/:sessionId/" ));
160
+ commandRepository .put (GET_SESSION , getC ("/session/:sessionId/" ));
154
161
commandRepository .put (GET_SUPPORTED_PERFORMANCE_DATA_TYPES ,
155
- postC ("/session/:sessionId/appium/performanceData/types" ));
162
+ postC ("/session/:sessionId/appium/performanceData/types" ));
156
163
commandRepository .put (GET_PERFORMANCE_DATA ,
157
- postC ("/session/:sessionId/appium/getPerformanceData" ));
158
-
164
+ postC ("/session/:sessionId/appium/getPerformanceData" ));
165
+ commandRepository .put (START_RECORDING_SCREEN ,
166
+ postC ("/session/:sessionId/appium/start_recording_screen" ));
167
+ commandRepository .put (STOP_RECORDING_SCREEN ,
168
+ postC ("/session/:sessionId/appium/stop_recording_screen" ));
159
169
//iOS
160
170
commandRepository .put (SHAKE , postC ("/session/:sessionId/appium/device/shake" ));
161
171
commandRepository .put (TOUCH_ID , postC ("/session/:sessionId/appium/simulator/touch_id" ));
162
172
commandRepository .put (TOUCH_ID_ENROLLMENT ,
163
173
postC ("/session/:sessionId/appium/simulator/toggle_touch_id_enrollment" ));
164
174
//Android
165
175
commandRepository .put (CURRENT_ACTIVITY ,
166
- getC ("/session/:sessionId/appium/device/current_activity" ));
176
+ getC ("/session/:sessionId/appium/device/current_activity" ));
167
177
commandRepository .put (END_TEST_COVERAGE ,
168
- postC ("/session/:sessionId/appium/app/end_test_coverage" ));
178
+ postC ("/session/:sessionId/appium/app/end_test_coverage" ));
169
179
commandRepository .put (GET_DISPLAY_DENSITY , getC ("/session/:sessionId/appium/device/display_density" ));
170
180
commandRepository .put (GET_NETWORK_CONNECTION , getC ("/session/:sessionId/network_connection" ));
171
181
commandRepository .put (GET_SYSTEM_BARS , getC ("/session/:sessionId/appium/device/system_bars" ));
172
182
commandRepository .put (IS_KEYBOARD_SHOWN , getC ("/session/:sessionId/appium/device/is_keyboard_shown" ));
173
183
commandRepository .put (IS_LOCKED , postC ("/session/:sessionId/appium/device/is_locked" ));
174
184
commandRepository .put (LONG_PRESS_KEY_CODE ,
175
- postC ("/session/:sessionId/appium/device/long_press_keycode" ));
185
+ postC ("/session/:sessionId/appium/device/long_press_keycode" ));
176
186
commandRepository .put (FINGER_PRINT , postC ("/session/:sessionId/appium/device/finger_print" ));
177
187
commandRepository .put (OPEN_NOTIFICATIONS ,
178
- postC ("/session/:sessionId/appium/device/open_notifications" ));
188
+ postC ("/session/:sessionId/appium/device/open_notifications" ));
179
189
commandRepository .put (PRESS_KEY_CODE ,
180
- postC ("/session/:sessionId/appium/device/press_keycode" ));
190
+ postC ("/session/:sessionId/appium/device/press_keycode" ));
181
191
commandRepository .put (PUSH_FILE , postC ("/session/:sessionId/appium/device/push_file" ));
182
192
commandRepository .put (SET_NETWORK_CONNECTION ,
183
- postC ("/session/:sessionId/network_connection" ));
193
+ postC ("/session/:sessionId/network_connection" ));
184
194
commandRepository .put (START_ACTIVITY ,
185
- postC ("/session/:sessionId/appium/device/start_activity" ));
195
+ postC ("/session/:sessionId/appium/device/start_activity" ));
186
196
commandRepository .put (TOGGLE_LOCATION_SERVICES ,
187
- postC ("/session/:sessionId/appium/device/toggle_location_services" ));
197
+ postC ("/session/:sessionId/appium/device/toggle_location_services" ));
188
198
commandRepository .put (UNLOCK , postC ("/session/:sessionId/appium/device/unlock" ));
189
- commandRepository . put (REPLACE_VALUE , postC ("/session/:sessionId/appium/element/:id/replace_value" ));
190
- commandRepository .put (GET_CURRENT_PACKAGE ,getC ("/session/:sessionId/appium/device/current_package" ));
199
+ commandRepository .put (REPLACE_VALUE , postC ("/session/:sessionId/appium/element/:id/replace_value" ));
200
+ commandRepository .put (GET_CURRENT_PACKAGE , getC ("/session/:sessionId/appium/device/current_package" ));
191
201
}
192
202
193
203
/**
@@ -246,8 +256,8 @@ public static AppiumCommandInfo deleteC(String url) {
246
256
*/
247
257
public static Map .Entry <String , Map <String , ?>> hideKeyboardCommand (String strategy ,
248
258
String keyName ) {
249
- String [] parameters = new String [] {"strategy" , "key" };
250
- Object [] values = new Object [] {strategy , keyName };
259
+ String [] parameters = new String []{"strategy" , "key" };
260
+ Object [] values = new Object []{strategy , keyName };
251
261
return new AbstractMap .SimpleEntry <>(
252
262
HIDE_KEYBOARD , prepareArguments (parameters , values ));
253
263
}
@@ -260,7 +270,7 @@ public static AppiumCommandInfo deleteC(String url) {
260
270
* @return built {@link ImmutableMap}.
261
271
*/
262
272
public static ImmutableMap <String , Object > prepareArguments (String param ,
263
- Object value ) {
273
+ Object value ) {
264
274
ImmutableMap .Builder <String , Object > builder = ImmutableMap .builder ();
265
275
builder .put (param , value );
266
276
return builder .build ();
@@ -274,7 +284,7 @@ public static ImmutableMap<String, Object> prepareArguments(String param,
274
284
* @return built {@link ImmutableMap}.
275
285
*/
276
286
public static ImmutableMap <String , Object > prepareArguments (String [] params ,
277
- Object [] values ) {
287
+ Object [] values ) {
278
288
ImmutableMap .Builder <String , Object > builder = ImmutableMap .builder ();
279
289
for (int i = 0 ; i < params .length ; i ++) {
280
290
if (!StringUtils .isBlank (params [i ]) && (values [i ] != null )) {
@@ -308,8 +318,8 @@ public static ImmutableMap<String, Object> prepareArguments(String[] params,
308
318
*/
309
319
public static Map .Entry <String , Map <String , ?>> pressKeyCodeCommand (int key ,
310
320
Integer metastate ) {
311
- String [] parameters = new String [] {"keycode" , "metastate" };
312
- Object [] values = new Object [] {key , metastate };
321
+ String [] parameters = new String []{"keycode" , "metastate" };
322
+ Object [] values = new Object []{key , metastate };
313
323
return new AbstractMap .SimpleEntry <>(
314
324
PRESS_KEY_CODE , prepareArguments (parameters , values ));
315
325
}
@@ -338,8 +348,8 @@ public static ImmutableMap<String, Object> prepareArguments(String[] params,
338
348
*/
339
349
public static Map .Entry <String , Map <String , ?>> longPressKeyCodeCommand (int key ,
340
350
Integer metastate ) {
341
- String [] parameters = new String [] {"keycode" , "metastate" };
342
- Object [] values = new Object [] {key , metastate };
351
+ String [] parameters = new String []{"keycode" , "metastate" };
352
+ Object [] values = new Object []{key , metastate };
343
353
return new AbstractMap .SimpleEntry <>(
344
354
LONG_PRESS_KEY_CODE , prepareArguments (parameters , values ));
345
355
}
@@ -349,7 +359,7 @@ public static ImmutableMap<String, Object> prepareArguments(String[] params,
349
359
* device locking.
350
360
*
351
361
* @param duration for how long to lock the screen for. Minimum time resolution is one second
352
- * @return a key-value pair. The key is the command name. The value is a
362
+ * @return a key-value pair. The key is the command name. The value is a
353
363
* {@link java.util.Map} command arguments.
354
364
*/
355
365
public static Map .Entry <String , Map <String , ?>> lockDeviceCommand (Duration duration ) {
@@ -402,4 +412,14 @@ public static ImmutableMap<String, Object> prepareArguments(String[] params,
402
412
Object [] values = new Object []{remotePath , new String (base64Data , StandardCharsets .UTF_8 )};
403
413
return new AbstractMap .SimpleEntry <>(PUSH_FILE , prepareArguments (parameters , values ));
404
414
}
415
+
416
+ public static Map .Entry <String , Map <String , ?>> startRecordingScreenCommand (BaseStartScreenRecordingOptions opts ) {
417
+ return new AbstractMap .SimpleEntry <>(START_RECORDING_SCREEN ,
418
+ prepareArguments ("options" , opts .build ()));
419
+ }
420
+
421
+ public static Map .Entry <String , Map <String , ?>> stopRecordingScreenCommand (BaseStopScreenRecordingOptions opts ) {
422
+ return new AbstractMap .SimpleEntry <>(STOP_RECORDING_SCREEN ,
423
+ prepareArguments ("options" , opts .build ()));
424
+ }
405
425
}
0 commit comments