Most Common Robot Writing Mistakes

Most Common Robot Writing Mistakes

We compiled a list of the most frequently occurring mistakes in robot creation. This list is based on our own experience and what we encounter when doing support for our customers. This list should help robot developers avoid coding pitfalls and steer towards best practices.

Multiple done() statements

Sometimes developers leave multiple done() instances inside a step. This causes unexpected robot behavior because done() sends a signal to controlling mechanism that the step is done and controlling mechanism can start the next step from queue.

Good

done() does not wait for asynchronous code to finish

A step should have done() placed so it is executed only when all work within a step is finished. Sometimes done() is placed where it executes before asynchronous code can finish, although visually it looks like done() is at the end of a step. Typical scenarios where this mistake occurs are when steps.waitFor or jQuery Ajax are present.

Code is placed outside any given step

Placing any code outside a step causes this code to be executed on every single page that robot opens. So placing instructions regarding retries, robots.txt or skipping visited links outside a step will re-execute these instruction changes on every single page load.