Prototyping Keywords
Contents
Prototyping Keywords¶
RobotKernel allows fast execution of individual keywords with or without arguments through Jupyter widgets. This is ideal for keyword prototyping or manually invoked automation.
Executable keywords¶
Every time a cell with *** Keywords ***
, but without tasks or tests cases, is executed for the first time, input fields for keyword arguments and buttons for keyword execution are being rendered below the cell.
To toggle visibility of the widgets, simply execute the cell again, unchanged.
(Note: Currently these widgets won’t get saved properly with notebook files so they should be hidden before saving the notebook.)
Re-executable keyword example¶
*** Keywords ***
Increment suite variable
[Arguments] ${increment}=1
${value}= Get variable value ${global value} 0
${value}= Evaluate ${value} + ${increment}
Set suite variable ${global value} ${value}
[Return] ${value}
For example, the above keyword Increment suite variable will render a single input field for its argument and a button to execute the keyword with the argument value being read from the input field.
Because RobotKernel keeps the state of custom suite level variables between executions, the keyword above allows incrementing a suite level variable with custom amount as long as the kernel is being restarted.
Example for Windows¶
Here’s a more complex example about automating Windows with WhiteLibrary. The example, which is written for Windows in Finnish language, defines keywords for opening Notepad application, inserting given texts into notepad window and saving the results with given filename.
*** Settings ***
Library WhiteLibrary
*** Tasks ***
Attach Notepad window
Launch application notepad.exe
Attach application by name notepad
Attach window Nimetön – Muistio
*** Keywords ***
Input into Notepad
[Arguments] ${text}=Here be dragons
Input text to textbox class_name=Edit ${text}\n
Clear notepad
Click menu button text=Muokkaa
Click menu button text=Valitse kaikki
Click menu button text=Muokkaa
Click menu button text=Poista
Save file
[Arguments] ${filename}=hello-world.txt
Click menu button text=Tiedosto
Click menu button text=Tallenna nimellä...
Input text to textbox text=Tiedostonimi: ${filename}
Select listbox value text=Koodaus: Unicode
Click button text=Tallenna