Keyboard and Clipboard Events
This section describes the Eggplant Functional commands and functions that act upon the SUT's keyboard and clipboard.
KeyDown Command
Behavior: Presses and holds the given keys until they are released by the KeyUp command.
Parameters: Keyboard characters (in quotation marks); TypeText keywords (with no quotation marks).
Syntax:
KeyDown keysToPress
Example:
KeyDown ControlKey, CommandKey, "d"
Example:
//Use code like this to select multiple items, such as files in File Explorer/Finder, and then copy the files
Click "FirstEntry" //Clicks the hot spot of image "FirstEntry"
KeyDown ControlKey //Holds down the control key
Click "LastEntry" //Clicks the hot spot of image "LastEntry"
KeyUp ControlKey //Releases the control key
RightClick //Right-clicks at the same location as the previous mouse event
Click "CopyMenuItem"
Related: KeyUp Command
KeyUp Command
Behavior: Releases keys that have been held by the KeyDown command.
Parameters: Keyboard characters (in quotation marks); TypeText keywords (with no quotation marks).
Syntax:
KeyUp keysToRelease
Example:
KeyUp ControlKey, CommandKey, "d"
Example:
KeyUp AllModifierKeys
Example:
//Use code like this to select a section of items, such as files in File Explorer/Finder, and then copy the files
Click "FirstEntry" //Clicks the hot spot of image "FirstEntry"
KeyDown ShiftKey //Holds down the shift key
Click "LastEntry" //Clicks the hot spot of image "LastEntry"
KeyUp ShiftKey //Releases the shift key
RightClick //Right-clicks at the same location as the previous mouse event
Click "CopyMenuItem"
You can use the keywords AllKeys, AllModifierKeys, and AllNonModifierKeys to release all keys of those respective groups.
Related: KeyDown Command
RemoteClipboard Function
This command is not supported by Sauce Labs.
Behavior: Returns the current text contents of the SUT's clipboard. The return is valid only if the clipboard has been used during the current VNC connection.
Parameters: Optional maximum wait time.
Syntax: remoteClipboard( {maxWaitTime} ) the remoteClipboard
Returns: Text contents of the SUT clipboard.
If you include a maximum wait time for the RemoteClipboard function, the function returns clipboard content that was added as a result of the last action on the SUT. If no new clipboard content is detected within the given time parameter, an error is raised.
If you do not specify a maximum wait time, the RemoteClipboard function returns the last known contents of the SUT's clipboard.
Example:
log remoteclipboard(5) //Returns content from the remote clipboard that was added by events executed against the SUT in the previous 5 seconds
Example:
assert the remoteClipboard is a number //Confirms that the content of the remote clipboard is a number
Example:
DoubleClick "ConfirmationNumber" //Doubleclicks a field to select its contents
TypeText controlKey, "c" //Sends the keystrokes to perform a copy action on the SUT
put remoteClipboard() into ConfNum //Stores the content of the SUT's remote clipboard into variable ConfNum
if ConfNum is not "8091283" then logWarning "The numbers don't match." //Validates whether the value of ConfNum matches the expected value, and if not, logs a warning
SetRemoteClipboard Command
This command is not supported by Sauce Labs.
Behavior: Puts given text into the SUT's clipboard. From here, you can paste it like any other text that is cut or copied on the SUT.
Parameters: One text string.
Syntax:
SetRemoteClipboard text
Example:
setremoteClipboard the time//Sends the current system time to the SUT clipboard
Click "TimeField"
TypeText ControlKey,"v" //Sends the keystrokes to the SUT to carry out the paste action
Example:
params HouseNumber //Parameterizes the script. Example parameter value: "2799"
setremoteclipboard HouseNumber //Sets the remote clipboard using the value passed to the script
//Code like this can bring up the paste menu on mobile
Press "AddressField" //Presses the hot spot location of the AddressField image
wait 2
Release //Releases the press
tap "PasteDialog"
TypeHiddenText Command
Behavior: Sends keystrokes to the SUT, but does not print that text to the Eggplant Functional log.
Parameters: Text strings enclosed in quotation marks. Can be used in conjunction with VaultValue commands.
Syntax:
TypeHiddenText [text | keyword]
Example:
TypeHiddenText "Bravely bold Sir Robin"
Example:
TypeHiddenText GetVaultValue("myVaultID")
Related: