GUI Automation with DogTail
Dogtail is a GUI test tool and automation framework written in Python. It uses Accessibility (a11y) technologies to communicate with desktop applications. dogtail scripts are written in Python and executed like any other Python program. dogtail is free software released under the GPL. Some example code is released to the Public Domain.
dogtail has a number of features that aid in the automation and testing of desktop applications. These include:
- Scripts written in Python - Since dogtail uses Python as its scripting language, scriptwriters gain enormous power and flexibility in what they can do with dogtail. If you can do it in Python, you can do it with dogtail.
- Procedural API - A procedural scripting API allows for fast and easy black box tests to be written. Ace programmer credentials are not necessary to write useful automated scripts.
- Easily Extensible - dogtail is object oriented "under the covers" so more advanced users can write custom classes and helper libraries simply.
- Results and debug reporting - Test case comparisons are written to a tab-delimited results file for easy processing. Debug information is written to its own log for detailed analysis of what happened during script execution.
Packages that are required:-
The following packages are required to use dogtail:
- AT-SPI-enabled desktop (GNOME at this point in time).
- Python 2.3 or higher (available through your distribution).
- ImageMagick 6.2 or higher (available through your distribution).
- rpm-python or python-apt (available through your distribution).
- ElementTree for Python (available through your distribution).
- pyspi - Python AT-SPI bindings.
Contribute Scripts
- Scripts - Information on writing dogtail scripts and application helper libraries.
- Framework - Information on helping to develop the core dogtail test framework.
- Bug tracking - Something broken? Let us know.
See the HACKING document for information on coding style. If you want to get involved with dogtail development, subscribe to the dogtail-devel list and join us on IRC. All patches should be attached to a Bugzilla bug/feature request.
You can find us in #dogtail on irc.freenode.net. If you're curious about anything dogtail-related, drop in and ask! We won't bite.
Bugs
The whole reason we created dogtail was to help us find bugs and, once they were fixed, to make sure that they stay fixed. However, since dogtail is still very much in development, we're sure you'll find bugs in our software too. File bug reports if you do, so we can fix them.
How does Dogtail work?
One of the main functions of any GUI testing framework is the identification of the elements in the GUI. It's possible to locate and identify GUI elements by their X and Y matrix coordinates, but this approach is limited by the requirement that the GUI layout not change. The better approach is to locate and identify the GUI elements as discrete objects that the test scripts can manipulate. Dogtail achieves this identification through the application GUI's accessibility information metadata.
Dogtail makes use of the Assistive Technology Service Provider Interface (AT-SPI1) accessibility framework. This is a part of the Gnome Accessibility Project (GAP2). AT-SPI provides a Service Provider Interface for the Assistive Technologies available on the GNOME platform, and a library against which applications can be linked.
Dogtail currently supports GNOME applications and many other GTK+ applications. Dogtail uses pyspi (a module written in Pyrex to give Dogtail access to AT-SPI's C API).
The predicate module supports searches for these types of GUI nodes:
- applications
- windows
- dialogs
- menus
- menu items
- text entries
- buttons
- tabbed panels
So far so good. But, what if you have to access a group of child GUI nodes all at once? Use the children attribute.
The "children" Attribute
The basic use of the children attribute is simply a logical extension. Where the child attribute returns a single child GUI node of he target node, the children attribute returns a Python List of all the child attributes of the target node. Easy, right?
. Suppose your target GUI node is the parent of multiple different types of GUI nodes, and you're only interested in accessing one type of node. With the children attribute, your Dogtail script will have to include logic to examine each child GUI node to determine if the node is of the type you want to access.
Fortunately, the predicate module provides an easy way to filter the type of child node that you retrieve from a target node. You do this my means of the findChildren() function. You control the type of child node in the Python List returned by this function by passing the function a parameter that specifies a"generic predicate." Here's an example that returns a List of all the GUI nodes of type combo box (the second parameter is a boolean that controls whether the search is recursive):
The Python advantage
We discussed earlier in the article that building Dogtail on Python made writing test scripts easy and supported Dogtail's object-oriented design. Another advantage of having Dogtail built on Python is that you can debug your test scripts with the Python interpreter. Using the interpreter is a great way to try things out quickly as you're learning Dogtail, as any statements that you can run in a Dogtail scripts can also be run by typing them into the interpreter.
Here's a sample taken from the example test scripts we just discussed. After you define the save button variable, you can get a directory of all the methods that are supported for it by just typing in the dir statement.
Dogtail @ cattechnologies:-
Here in CAT we always try giving the client better solutions every day. Dogtail is a relatively new concept where the testers can help the developers by giving better approach is to locate and identify the GUI elements as discrete objects that the test scripts can manipulate. Dogtail achieves this identification through the application GUI's accessibility information metadata. We started using the dogtail tool to test the applications.
Posted by: Rani Agasti