Chapter 1. Instant Sikuli Test Automation

Welcome to Instant Sikuli Test Automation. This book has been specially created to provide you with all the information that you need to get started with Sikuli, and develop automated testing scripts. You will learn the basics of Sikuli, get started with building your first test, and discover a variety of tips, tricks, and techniques for using Sikuli for automated testing.

This book contains the following sections:

So, what is Sikuli? tells you more about Sikuli, which is an automation tool, that uses a combination of screenshots and computer vision techniques to allow control of any application on the screen.

Installation explains how to download and install Sikuli with minimum fuss, and then set it up so that you can use it as soon as possible.

Quick start – writing your first script teaches you how to create your first automated script using Sikuli, and demonstrates how to use its most basic features.

Top 13 features you need to know about helps you explore the most important features of Sikuli, and learn to use it like a pro. By the end of this section you will be able to:

  • Write simple tests using Sikuli’s basic features
  • Create more complex tests using flow control, events, and good methods for structuring tests to allow code reuse
  • Build a library of reusable test fragments that will reduce the maintenance burden for a large test suite
  • Put all of the previously mentioned techniques together into a framework for running your tests and reporting results

People and places you should get to know provides you with many useful links to the project page and forums, as well as a number of helpful articles, tutorials and blogs, as every open source project is centered around a community.

So, what is Sikuli?

Sikuli allows you to automate anything you see on the screen, using screenshots as a means of control. It provides you with an editor for creating scripts using its API in combination with the Python programming language to give its users a great deal of flexibility in how they construct their scripts.

What can you do with Sikuli? That all depends on how much effort you want to put into the script. You can crawl through websites using it, when tools like cURL don't work. You can watch the screen for particular features to appear, and then execute scripts in response. Since Sikuli provides you with a rich programming environment via Python, the only limit is your ability to figure out how to accomplish something.

The Sikuli IDE provides you with your primary interface for working with and executing Sikuli scripts. Here, we can get a quick overview of the components of the UI:

So, what is Sikuli?

The toolbar contains buttons for common actions in Sikuli. From left to right these are:

  • Take screenshot: This is used when capturing portions of the screen for use in your scripts
  • Insert image: This lets you select an existing image to search for on the screen
  • Create Region: This lets you create a region on the screen to reference in your scripts
  • Run: This will execute your script
  • Run in slow motion: This will execute your script in slow motion, which can be extremely handy for debugging Sikuli scripts
  • Find: This lets you search for text in your Sikuli script code

The bar on the left provides a list of common commands and their arguments. You can double-click on any of these commands, and they will be inserted into your script. For example, if you double-click on the exists() command, it will insert it into your script, and immediately put Sikuli into the capture mode to make a screen selection. This selection will then be inserted into the exists() command in your script.

The editor provides you with a way to create and change your scripts. For every open script there is a tab. Generally speaking, you'll want to use Sikuli's editor for writing scripts, since it provides you a good way to see what your scripts are doing and interact with the screenshots. The editor has a few quirks, but considering the additional features it provides, specific to Sikuli (and the need to synchronize multiple files in the underlying file format), it is an important tool for working with Sikuli.

Finally, there's a small console at the bottom of the UI, which provides feedback about running scripts. If your script generates console output or fails due to an error, it will be noted here.

Sikuli provides an excellent platform for automated testing of applications. Through the use of screenshots and simple commands, it makes it much easier for non-programmers to create tests, and provides a good introduction for testers to the greater power that scripting provides. Testers can start out simply, and add more complexity as they become familiar with the tool and need to expand their ability to do more complex testing. Since Sikuli uses a common programming language instead of something unique to the tool, there is a wealth of information available on the Internet about learning how to program using Python.

Sikuli can integrate with your existing testing tool pipeline. Using Python, it is possible to have your Sikuli tests do things like automatically submit test results to an existing test tracking system such as JIRA, Zephyr, or Testopia. This would require some additional scripting in Python, but with a little bit of effort, it is possible to integrate Sikuli with any tools of this kind that support access via some sort of web-based API.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset