Automated testing: Sikuli, a GUI testing framework based on interface images

Source: Internet
Author: User
Tags sikuli

Http://www.sikuli.org/license:MITscript Language:python
Here's an example of his Hello world, and it's interesting to see. There are lots of interesting things in the open source world, we should take more time to understand them and then use different tools in different scenes. Hello World (MAC)

Let us begin with a customary Hello world example!

You'll learn how to capture a screenshot of a GUI element and the write a Sikuli Script to do the things:

    1. Click on the That element
    2. Type a string in that element

The goal of the ' Hello World ' is to automatically type ' Hello World ' into the ' Spotlight search box, like this:

now, open the Sikuli IDE. We begin by taking the screenshot of our target, the Spotlight symbol in the upper-right corner, so that we can tell Sikul I Script what to look for and click on.

to simulate a mouse click on the Spotlight symbol, we is going to use THE click  function. To tell Sikuli how the target looks like, we need to capture the target's image on the screen.

Sikuli IDE provides, methods to capture screen images. The first method is to click on the camera button in the toolbar. This would bring the screen capturing mode.

The second method is to press a hot-key (Command + Shift + 2). Often the target whose image you wish to capture may is covered by the Sikuli IDE ' s window. You can minimize the IDE's window and use this hot-key-to-switch to the capturing mode.

In the screens capturing mode, the screen would look darker and freeze momentarily. The entire desktop becomes like a canvas where can draw a rectangle around the target of your want to capture an image of. In this case, the target is the spotlight symbol. The cross of red dotted lines shows the center of the rectangle you just drew.

After you have drawn (or selected) a rectangle, the image within the rectangle would be captured and inserted into the SCRI PT Editor at the current cursor position.

Now, you can write the click function using this image as a argument to tell Sikuli to click on Spotlight symbol.

As a convenience, Sikuli IDE provides a Command List on the left panel. It shows a list of the most often used functions. Camera icons in the functions indicate these functions expect a captured image as an argument.

Locate the Click () function in the list and click on it. If Auto capture is on (default), you'll be directed to the screen capturing mode in which you can Capture an IM Age of a interface target to is inserted into the click () function as an argument.

The next step is to tell Sikuli to enter the string "Hello world" into Spotlight's search box, which can be do with a Si Mple typefunction.

This function would type the string given in the argument to whichever input control that has the focus. After clicking on the spotlight symbol, we can expect the spotlight search box would be the input, which has the focus.

congratulations! You have just completed your first Sikuli Script. Press the Run button to see this script in action!


Source: >  

From for notes (Wiz)

Automated testing: Sikuli, a GUI testing framework based on interface images

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.