Browser Automation Functions
The following functions manipulate the browser in various ways. Note that, wherever a {selector} is used, a reference to an IWebElement (returned by Find or the argument(s) of Find can be used instead.
id Add2InputValue (t1 t2)
While SetInputValue replaces the complete text of the control, Add2InputValue can be used to prepend or append text to the current value of the control. t1 will be prepended, t2 appended. Use '' to avoid the related change.
ClearInput
Clears the content of input-fields or textarea.
{selector} Click id
Clicks on the selected element. Both arguments are passed directly to the Find function, and the Click method is invoked on the result. For example:
Click 'btn1'
{R}←{args}ExecuteScript sc
Executes the Javascript code passed in sc. The optional left argument can be used to pass arguments to it.
A good use case for this is this line of the SetInputValue function:
(obj text)ExecuteScript'arguments[0].value = arguments[1];'
fromid DragAndDrop toid
Drag the element 'draggable'#.S.DragAndDrop'droppable'
fromid DragAndDropToOffset xy
Drag the element 'draggable'#.S.DragAndDropToOffset 10 10
R←{level}GetLogs type
This function retrieves the logs. Valid values for type are browser, webdriver and performance, the optional level must be one of All, Debug, Info, Off, Severe or Warning.
Info
By default, only browser and webdriver logs are enabled.
If you want to access performance logs, they needs to be enabled in settings.json5 first.
{action} MoveToElement toid [x y]
Move the mouse to the middle of an element, or optionally to the (x y) coordinates.
If the optional left argument is provided and is a character vector containing one of the strings Click | ClickAndHold | ContextClick | DoubleClick, that mouse action will be performed after the move.
For example:
'DoubleClick' MoveToElement 'btn1' 10 10
{ok}←id Select text
Select the item with a given text in a dropdown. For example:
'fruits' Select 'apples'
The right argument text can also be a two-element vector containing (srch crit)where
srchspecifies what you're searching for- and
critdescribes the criteria:CssSelector: find the element using a CSS SelectorIndex:srchgives the index of the element you want to selectPartialText:srchis a partial textText:srchis the full text that needs to matchValue:srchmust match thevalueattribute of the element you're looking for- a boolean value in
critindicates whether partial matches are accepted (=1) or not (=0, default)
The boolean result ok indicates if the selection was successful (=1) or not (=0).
{ok}←id SelectItemText text
Much like the previous function, this function can be used to select elements in a select control based on the item text. While it does not provide the flexibility regarding selections, it also enables you to de-select elements by providing a prefix - and to de-select all element by passing the value ~.
id SendKeys text
see separate doc
id SetInputValue text
This method is an alternative to SendKeys. While SendKeys focusses on sending actual keystrokes, this function provides an easy way to send text to an input control. It is recommended when sending "complex" text that may require key-combinations to enter it, for example APL-Symbols or special characters like "@".