My first Execution
Prerequisite: a local step installation
This short guide will walk you through the creation and execution of a “hello world” automation scenario. For demonstration purposes, we will use step’s built-in editor to edit a basic javascript Keyword and invoke it from a Plan. Advanced script design requires the use of libraries, so in the next section of the guide, we will switch to an external IDE such as Eclipse.
What’s a Keyword?
Conceptually speaking, Keywords can be seen as the reflection of a piece of business logic which a human (or a process) would otherwise perform. At the technical level, a Keyword is represented by a code package or “script”, which performs a specific action against a target system. Upon execution, information can be passed to the Keyword dynamically as an input, as well as extracted from the subject of the automation and returned as an output. You can find out more about Keywords in the dedicated section of our documentation.
When using and leveraging the Keyword API at industrial scale, many benefits arise from using Keywords as a building block, such as out-of-the-box scalability via the distribution of Keyword executions, execution traceability, reporting and a strong basis to base and organize automation code upon.
Keyword creation
step supports a vast array of languages and runtimes, each potentially favoring a different IDE for Keyword development. However, we’ll go straight to the point here and create a basic Javascript Keyword which will run on top of step’s Java agent, via Java’s ScriptEngine interpreter.
First, click the Keywords tab in step’s web application, and then click the New Keyword button.
Enter a name for your newly created Keyword (for instance “MyFirstKeyword”). Make sure to select javascript as a engine type, then click the Save and edit button, which will take you automatically to step’s built-in editor.
A basic script template is provided at creation time, which we’ll use as a basis for our new Keyword. What this template does by default is nothing more than returning any inputs back as an output. In our Keyword, we will simply create an arbitrary variable to store the current date and return it as an output.
Let’s add the following line of code to assign the current date to a variable called myDate.
var myDate = new Date()
And modify the last line of the script template to return our new dynamic value in the JSON output of the Keyword call:
context.setPayloadJson('{ "myDate" : "' + myDate + '"}');
Your script should look something like this:
Let’s create a plan in order to execute our Keyword.
What’s a plan?
Plans are the implementation of an automation scenario and can be designed using different formats but in this example, we will use step’s visual editor by default. They are structured as a tree of nodes which will be executed sequentially by default.
As explained in detail in the dedicated section of the documentation, Plans can represent any sort of automation asset, ranging from a test case, to a load scenario, an RPA routine, or even a monitoring probe. They usually combine the execution of Keywords with various control structures. Once a Plan has started, execution ensues and Keywords are distributed on the available agents.
Plan creation
Let’s now click the Plans tab and create a new plan by clicking on the New plan button.
Let’s name our plan and click the Save and edit button, which will take us to the plan editor.
We’ll search for our newly created Keyword in the Keyword library on the right side of the screen and add it to our plan.
An instance of the Keyword’s call should now appear in your plan’s tree.
First execution
Let’s now execute our plan by clicking the play icon in the top right and then the play icon that opened.
As you can see, the corresponding script was executed, and the current date is provided as an output.
You can find out more about executions in the corresponding section of our documentation.
We now encourage you to move on to a more complex scenario such as Selenium-based browser automation, and also to take a look at our plan library and the rest of our documentation pages to get a better sense of all the possibilities offered by Keywords and Plans.