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
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:
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 :
- Visual Studio 2008 Test Types [Article]
- Android Application Testing: Getting Started [Article]
- Python Testing: Installing the Robot Framework [Article]
|Discover automated application testing techniques for anything that is visible on the computer screen with this book and ebook|
eBook Price: $14.99
About the Author :
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.