{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Executing keywords directly" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "RobotKernel allows fast execution of individual keywords with or without arguments through Jupyter widgets." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Every time a cell with `*** Keywords ***`, but without tasks or tests cases, is executed for the first time, argument input fields widgets and keyword execution buttons are being rendered below the cell. **To toggle visibility of the widgets, simply execute the cell again, unchanged.** (Currently these widgets won't get saved properly with notebook files so they should be hidden before saving the notebook.)" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "*** Keywords ***\n", "\n", "Increment suite variable\n", " [Arguments] ${increment}=1\n", " ${value}= Get variable value ${global value} 0\n", " ${value}= Evaluate ${value} + ${increment}\n", " Set suite variable ${global value} ${value}\n", " [Return] ${value}" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "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." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Because RobotKernel keeps the state of custom suite level variables, the keyword above allows incrementing a suite level variable with custom amount as long as the kernel is being restarted." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "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." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "*** Settings ***\n", "\n", "Library WhiteLibrary" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "*** Tasks ***\n", "\n", "Attach Notepad window\n", " Launch application notepad.exe\n", " Attach application by name notepad\n", " Attach window Nimetön – Muistio" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "*** Keywords ***\n", "\n", "Input into Notepad\n", " [Arguments] ${text}=Here be dragons\n", " Input text to textbox class_name=Edit ${text}\\n\n", "\n", "Clear notepad\n", " Click menu button text=Muokkaa\n", " Click menu button text=Valitse kaikki\n", " Click menu button text=Muokkaa\n", " Click menu button text=Poista\n", " \n", "Save file\n", " [Arguments] ${filename}=hello-world.txt\n", " Click menu button text=Tiedosto\n", " Click menu button text=Tallenna nimellä...\n", " Input text to textbox text=Tiedostonimi: ${filename}\n", " Select listbox value text=Koodaus: Unicode\n", " Click button text=Tallenna" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Robot Framework", "language": "robotframework", "name": "robotkernel" }, "language_info": { "codemirror_mode": "robotframework", "file_extension": ".robot", "mimetype": "text/plain", "name": "robotframework", "pygments_lexer": "robotframework" } }, "nbformat": 4, "nbformat_minor": 2 }