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 TypeText keyword, "b"

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 TypeText keyword, "b"

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"

Tip: You can use the keywords AllKeys, AllModifierKeys, and AllNonModifierKeys to release all keys of those respective groups.

Related: KeyDown Command

RemoteClipboard Function

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()

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

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.

Example:

TypeHiddenText "Bravely bold Sir Robin"

Example:

TypeHiddenText GetVaultValue("myVaultID")

Related:

TypeText Command

Behavior: Sends keystrokes to the to SUT. If modifier keys are sent, they are released when the entire command has been executed. To send a modifier that is not released automatically, use the "up" and "down" modifier keywords, such as ShiftUp and ShiftDown. To send any key that is not released automatically, use the KeyDown and KeyUp commands.

Parameters: Text strings enclosed in quotation marks, keywords for non-character keys, and text literals (blocks of text) in double angle brackets (<< >>). For a complete list of these keywords, see TypeText Keywords.

Syntax:

TypeText { "text" | TypeText keyword | <<text>> }

Example:

Typetext<<Dear diary,

>>& the date

//Types the string, followed by a return, followed by the date as returned by the date function, into the SUT

Example:

params Message

//Do some stuff

typetext Message //Types the value stored in the variable "Message"

Example:

put {first:"Bob", last:"Walker", age:42} into Customer

TypeText Customer.age //Types 42 into the SUT

Example:

TypeText WindowsKey, "r" //Sends the necessary keystrokes to the SUT to open the Windows Run dialog box

Example:

TypeText AltKey,F4 //Sends the necessary keystrokes to the SUT to close an app on desktop

Tip: When you are using the TypeText panel to create a command, clicking the Insert button automatically encloses your text parameters in quotation marks.

 

This topic was last updated on August 19, 2021, at 03:30:51 PM.

Eggplant icon Eggplantsoftware.com | Documentation Home | User Forums | Support | Copyright © 2022 Eggplant