Write Well-Structured Robots

Writing well-structured Web Automation robots is essential because each robot is a program. Writing well-structured robots is important because:

  • It helps document the robots.
  • It makes it easier to maintain the robots.
  • It makes it easier to find your way around the robots.

A side-effect of writing well-structured robots is that it can also make them load faster in Design Studio. As a result, robots are generally more responsive when they are edited in the Robot View.

The two main tools for writing well-structured Web Automation robots are Snippet steps and Group steps. Both step types are a way to take a part of a robot, give it a descriptive name, and pack it up in a single step. This way you can forget what the part of the robot does in detail and concentrate on the overall structure of the robot. This concept is similar to those in other programming languages, such as methods, functions, and procedures.

You use a group step to pack up and hide steps that perform a well-defined task. Give the step a descriptive name, such as Login to site X, Report error. It is important to give a relatively short descriptive name to the group step that describes what the steps inside the group do. If you cannot provide a good name, then it may be because the group does not perform a well-defined task. By introducing a group step you help document your robot, because the name describes what this part of the robot does.

Although snippets are mainly introduced to share functionality between robots, they can also be used inside a single robot to help structure it. If you have a collection of steps in a robot used in several branches, such as connections from different parts of the robot joining at the start of the steps, you can replace such steps sharing by introducing a snippet containing the steps.

The following robot structure uses snippets and groups instead of joining connections.


Sharing steps using joining tables

The last two steps c and d are shared by the two branches starting with the steps a and e. In real life, you probably have a much larger robot and more than two branches sharing steps in this way, and the steps involved may be far apart. As a result, it may be difficult to get an overview of the robot. As a first step towards getting a better structured robot, you can introduce a snippet step containing the steps c and d as follows.


Sharing steps using a snippet

You can edit the steps inside the snippet steps and still be sure that the changes are shared in the two branches. You can structure the robot further by putting both branches into a group step:


Grouping the branches steps

Finally, you can use the two group steps and get the following simple robot.


Restructured Robot

This resulting robot does two tasks, one performed by Group1 and the other performed by Group2. By giving these two groups descriptive names, the robot has a more logical structure than the original robot.

Admittedly, this is a very simple example, but when robots get beyond a certain size and contain connections crisscrossing the Robot View, they can become overly complex. Restructuring the robot in the manner described above may help ensure that the robot overview is manageable.