Options for checking your RPA scripts
As you build out your automation scripts with Robot Framework, they will become more complex and will likely take some time to run. This becomes even more of a problem once more people start helping you with these scripts and contributing to it through source control. It’s a good idea to make sure that every
.robot file is checked for correctness, style issues, and possible syntax errors. There are tools that can assist with statically checking that work without actually executing any of it. This will save you time, and catch problems earlier.
The most accessible option for checking your
.robot files is to use Robot Framework’s
--dryrun feature. This option is built into the framework and can be used immediately without installing anything else. It checks
.robot files for syntax errors, missing library dependencies, and it also generates all of the same results output as the regular
robot command without actually running any keywords.
Another option is Bryan Oakley’s robotframework-lint (also known as
rflint). This is an external linter specifically for checking
.robot files and does not utilize any of the internals of Robot Framework. A linter is a static analysis tool that can help identify style issues and other errors in source code. The
robotframework-lint tool needs to be installed by running
pip install --upgrade robotframework-lint in your terminal or command-line prompt.
Both options can be used by running
robot --dryrun <robot-file-name> and
rflint <robot-file-name> in your terminal or command-line prompt. It’s a good practice to first run the
--dryrun option and fix any syntax or library dependency problems identified by it. Then run
rflint to identify and fix any possible style issues. Here are some examples of the capabilities of both options.
Create a file on your machine called
check-this-script.robot and save the following in it.
Then open a terminal or command-line prompt and go to the specific directory that contains your
check-this-script.robot file, and make sure it’s there by running either
ls (macOS or Linux users) or
dir (Windows users). When you are ready, run the following command.
The following problems should have been identified and displayed after running that command. This should have also generated
output.xml result files.
From that same terminal or command-line prompt run the following command.
The following problems should have been identified and displayed after running that command.
See robotframework-lint for more instructions on how to use and configure the
Robot Framework and external tools provide ways for checking your robot scripts. Using them is optional, but they might provide value when your scripts get more complex or when you want to enforce a specific style (such as maximum line lengths) inside your project.