/** * Start asynchronous screen recording process. * * @param options see the documentation on the {@link BaseStartScreenRecordingOptions} * descendant for the particular platform. * @return Base-64 encoded content of the recorded media file or an empty string * if the file has been successfully uploaded to a remote location (depends on the actual options). */ default <T extends BaseStartScreenRecordingOptions> String startRecordingScreen(T options) { return CommandExecutionHelper.execute(this, startRecordingScreenCommand(options)); }
/** * Gather the output from the previously started screen recording to a media file. * * @param options see the documentation on the {@link BaseStopScreenRecordingOptions} * descendant for the particular platform. * @return Base-64 encoded content of the recorded media file or an empty string * if the file has been successfully uploaded to a remote location (depends on the actual options). */ default <T extends BaseStopScreenRecordingOptions> String stopRecordingScreen(T options) { return CommandExecutionHelper.execute(this, stopRecordingScreenCommand(options)); }
/** * Performs images matching to calculate the similarity score between them. * The flow there is similar to the one used in * {@link #findImageOccurrence(byte[], byte[], OccurrenceMatchingOptions)}, * but it is mandatory that both images are of equal size. * * @param base64image1 base64-encoded representation of the first image * @param base64Image2 base64-encoded representation of the second image * @param options comparison options * @return Matching result. The configuration of fields in the result depends on comparison options. */ default SimilarityMatchingResult getImagesSimilarity(byte[] base64image1, byte[] base64Image2, @Nullable SimilarityMatchingOptions options) { Object response = CommandExecutionHelper.execute(this, compareImagesCommand(ComparisonMode.GET_SIMILARITY, base64image1, base64Image2, options)); //noinspection unchecked return new SimilarityMatchingResult((Map<String, Object>) response); }
/** * This method forms a {@link java.util.Map} of parameters for the * key event invocation. * * @param key code for the key pressed on the device. * @return a key-value pair. The key is the command name. The value is a * {@link java.util.Map} command arguments. */ public static Map.Entry<String, Map<String, ?>> pressKeyCodeCommand(int key) { return new AbstractMap.SimpleEntry<>( PRESS_KEY_CODE, prepareArguments("keycode", key)); }
/** * Send a long key event to the device. * * @param key code for the key pressed on the device. */ default void longPressKeyCode(int key) { CommandExecutionHelper.execute(this, longPressKeyCodeCommand(key)); }
/** * Hides the keyboard by pressing the button specified by keyName if it is * showing. * * @param keyName The button pressed by the mobile driver to attempt hiding the * keyboard. */ default void hideKeyboard(String keyName) { CommandExecutionHelper.execute(this, hideKeyboardCommand(keyName)); }
/** * Lock the device (bring it to the lock screen) for a given number of * seconds or forever (until the command for unlocking is called). The call * is ignored if the device has been already locked. * * @param duration for how long to lock the screen. Minimum time resolution is one second. * A negative/zero value will lock the device and return immediately. */ default void lockDevice(Duration duration) { CommandExecutionHelper.execute(this, lockDeviceCommand(duration)); }
/** * Check if the device is locked. * * @return true if the device is locked or false otherwise. */ default boolean isDeviceLocked() { return CommandExecutionHelper.execute(this, getIsDeviceLockedCommand()); } }
/** * Check if the keyboard is displayed. * * @return true if keyboard is displayed. False otherwise */ default boolean isKeyboardShown() { return CommandExecutionHelper.execute(this, isKeyboardShownCommand()); } }
/** * Get settings stored for this test session It's probably better to use a * convenience function, rather than use this function directly. Try finding * the method for the specific setting you want to read. * * @return JsonObject, a straight-up hash of settings. */ @SuppressWarnings("unchecked") default Map<String, Object> getSettings() { Map.Entry<String, Map<String, ?>> keyValuePair = getSettingsCommand(); Response response = execute(keyValuePair.getKey(), keyValuePair.getValue()); return ImmutableMap.<String, Object>builder() .putAll(Map.class.cast(response.getValue())).build(); } }
/** * This method forms a {@link java.util.Map} of parameters for the * long key event invocation. * * @param key code for the long key pressed on the device. * @return a key-value pair. The key is the command name. The value is a * {@link java.util.Map} command arguments. */ public static Map.Entry<String, Map<String, ?>> longPressKeyCodeCommand(int key) { return new AbstractMap.SimpleEntry<>( LONG_PRESS_KEY_CODE, prepareArguments("keycode", key)); }
/** * Send a long key event along with an Android metastate to an Android device. * Metastates are things like *shift* to get uppercase characters. * * @param key code for the key pressed on the Android device. * @param metastate metastate for the keypress. */ default void longPressKeyCode(int key, Integer metastate) { CommandExecutionHelper.execute(this, longPressKeyCodeCommand(key, metastate)); } }
/** * Hides the keyboard if it is showing. Hiding the keyboard often * depends on the way an app is implemented, no single strategy always * works. * * @param strategy HideKeyboardStrategy. * @param keyName a String, representing the text displayed on the button of the * keyboard you want to press. For example: "Done". */ default void hideKeyboard(String strategy, String keyName) { CommandExecutionHelper.execute(this, hideKeyboardCommand(strategy, keyName)); } }
/** * Lock the device (bring it to the lock screen) for a given number of * seconds or forever (until the command for unlocking is called). The call * is ignored if the device has been already locked. * * @param duration for how long to lock the screen. Minimum time resolution is one second. * A negative/zero value will lock the device and return immediately. */ default void lockDevice(Duration duration) { CommandExecutionHelper.execute(this, lockDeviceCommand(duration)); }
/** * Check if the device is locked. * * @return true if the device is locked or false otherwise. */ default boolean isDeviceLocked() { return CommandExecutionHelper.execute(this, getIsDeviceLockedCommand()); } }
/** * Check if the keyboard is displayed. * * @return true if keyboard is displayed. False otherwise */ default boolean isKeyboardShown() { return CommandExecutionHelper.execute(this, isKeyboardShownCommand()); } }
/** * Get settings stored for this test session It's probably better to use a * convenience function, rather than use this function directly. Try finding * the method for the specific setting you want to read. * * @return JsonObject, a straight-up hash of settings. */ @SuppressWarnings("unchecked") default Map<String, Object> getSettings() { Map.Entry<String, Map<String, ?>> keyValuePair = getSettingsCommand(); Response response = execute(keyValuePair.getKey(), keyValuePair.getValue()); return ImmutableMap.<String, Object>builder() .putAll(Map.class.cast(response.getValue())).build(); } }
/** * This method forms a {@link java.util.Map} of parameters for the * keyboard hiding. * * @param keyName The button pressed by the mobile driver to attempt hiding the * keyboard. * @return a key-value pair. The key is the command name. The value is a * {@link java.util.Map} command arguments. */ public static Map.Entry<String, Map<String, ?>> hideKeyboardCommand(String keyName) { return new AbstractMap.SimpleEntry<>( HIDE_KEYBOARD, prepareArguments("keyName", keyName)); }
/** * Start asynchronous screen recording process. * * @param options see the documentation on the {@link BaseStartScreenRecordingOptions} * descendant for the particular platform. * @return Base-64 encoded content of the recorded media file or an empty string * if the file has been successfully uploaded to a remote location (depends on the actual options). */ default <T extends BaseStartScreenRecordingOptions> String startRecordingScreen(T options) { return CommandExecutionHelper.execute(this, startRecordingScreenCommand(options)); }
/** * Gather the output from the previously started screen recording to a media file. * * @param options see the documentation on the {@link BaseStopScreenRecordingOptions} * descendant for the particular platform. * @return Base-64 encoded content of the recorded media file or an empty string * if the file has been successfully uploaded to a remote location (depends on the actual options). */ default <T extends BaseStopScreenRecordingOptions> String stopRecordingScreen(T options) { return CommandExecutionHelper.execute(this, stopRecordingScreenCommand(options)); }