Debugging Sikuli scripts

Exclusive offer: get 50% off this eBook here
Instant Sikuli Test Automation [Instant]

Instant Sikuli Test Automation [Instant] — Save 50%

Discover automated application testing techniques for anything that is visible on the computer screen with this book and ebook

$14.99    $7.50
by Ben Lau | August 2013 | Open Source Web Graphics & Video

This article by Ben Lau, the author of Instant Sikuli Test Automation [Instant], will help you with the debugging of the Sikuli scripts. This article outlines two methods for debugging scripts:

  • Debugging by looking at the logs
  • Debugging by recording videos of your test runs

(For more resources related to this topic, see here.)

This is the last topic with test automation is the debugging of scripts. A portion of all time working on script development will be spent running the script trying to debug problems with the scripts to get them to run reliably. Once you have a collection of scripts that you run on a regular basis without supervision, identifying causes of errors can become much more difficult.

There are two main techniques for debugging Sikuli scripts when running them in the test harness presented here. The first method is to look at the logs. If you look back over the test runner script, you can see that it logs a complete record of the console output to a file. These files end in .final.log. You can open these in your text editor, and see what your script did and get feedback about the errors. The errors in the logs will tell you what happened. For example, you might get something like this:

This one is telling us that Sikuli couldn't find the requested image on the screen. Or, you might see errors with your Python code.

In situations like this, it's handy to know that Sikuli scripts are just a collection of files in a directory. You can actually open it up and look at the images and Python code within it. Another handy technique is to record videos of your test runs. This allows you to review what happened during a test (passing or failing) to see what went wrong, or analyze the execution for possible improvements to execution speed. For Mac OS X, this can be done using QuickTime Player, which is included with the OS. For Windows or Linux, you will need to investigate a similar solution solution (the examples prepared for this book contain a working example for Windows), but the general technique should still apply. Let's see how this would work in practice.

Firstly, we need to create two additional scripts, one to start recording and another to stop it. The script is broken into two parts, so they can be executed independently. Here's the startup script (see startcapture.sikuli):

And here's the script to stop recording (see stopcapture.sikuli):

These are then pretty easy to integrate with our test runner scripts (see runtests_withrecording.sikuli):

Depending on your machine, you may also encounter some performance degradations when recording video along with your tests. To compensate, you can adjust the default amount of time that Sikuli will wait to find something from 5 seconds to 10 seconds, or more (you may need to experiment), by adding the following line to the end of your library.sikuli script:

Summary

This article helped you debug your Sikuli scripts either by looking at the logs or by recording videos of your test runs.

Resources for Article :


Further resources on this subject:


Instant Sikuli Test Automation [Instant] Discover automated application testing techniques for anything that is visible on the computer screen with this book and ebook
Published: July 2013
eBook Price: $14.99
See more
Select your format and quantity:

About the Author :


Ben Lau

Ben Lau has worked as a software and build engineer since the mid 90s. He began his career as an intern for a major university in Southern California, working on virtual reality training systems, and continued there for almost 10 years, working on a variety of projects. After leaving the university to join a spin-off developing language training applications for the military,he began to specialize in build and release engineering and also branched out into automated testing. He is currently employed at a midsized startup in the Los Angeles area, working as their build and release manager.

Books From Packt


Python Testing: Beginner's Guide
Python Testing: Beginner's Guide

Python Testing Cookbook
Python Testing Cookbook

 Python 3 Object Oriented Programming
Python 3 Object Oriented Programming

Python Geospatial Development
Python Geospatial Development

Expert Python Programming
Expert Python Programming

Python 3 Web Development Beginner's Guide
Python 3 Web Development Beginner's Guide

Python Text Processing with NLTK 2.0 Cookbook
Python Text Processing with NLTK 2.0 Cookbook

Python 2.6 Graphics Cookbook
Python 2.6 Graphics Cookbook


Your rating: None Average: 1.5 (4 votes)

Post new comment

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
w
t
f
8
9
d
Enter the code without spaces and pay attention to upper/lower case.
Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Resources
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software