Extended Monitoring Guide

  • Docs Home
  • Community Home

4. Creating twill Commands

ZenWebTx uses a language called twill to specify the steps of a Web test. Each WebTx data source has a field that contains the twill commands that describe a Web transaction. You can create this list of twill commands manually, or you can record a session in a browser and use that as the basis for your data source.

Some twill commands specify an action, such as following a specific link on a page or entering data in a form field. Other twill commands specify a test, such as searching for specific text on a page or making sure the title does not contain specific text. The full range of available commands is described in the appendix Appendix A, twill Commands Reference.

4.1. Creating twill Commands from TestGen4Web

The TestGen4Web Firefox add-on allows you to record browser sessions. ZenWebTx can take these sessions and convert them to twill, creating a starting point for developing ZenWebTx data sources.

Follow these general steps to record and convert a TestGen4Web session:

  1. From the TestGen4Web toolbar in Firefox, use the Record and Stop buttons to record a session.

  2. Use the Save button in the toolbar to save the session to a file.

  3. From the Script page of a ZenWebTx data source in Zenoss, browse to and select your saved session.

  4. Click Save to convert the TestGen4Web session to twill. The newly converted commands appear in the Twill Commands field on the page, replacing any previous twill commands in that area.

4.2. Creating twill Commands Manually

Even if you use TestGen4Web to initially create twill commands, you will frequently want to edit these commands manually to add data points or additional content checks. The Appendix A, twill Commands Reference describes in detail the commands that you can use. The Test Twill Commands button on the Script page is helpful when testing twill commands as you create or edit them.

You also can execute twill commands interactively by using the twill-sh program from the command line. This program lets you enter commands one at a time and then inspect the pages that come back.

Invoke twill-sh with:

> PYTHONPATH=$ZENHOME/Products/ZenWebTx/lib
$ZENHOME/Products/ZenWebTx/bin/twill-sh

Within twill-sh, use the help command to list available commands and see a command descriptions. Of particular interest are these commands:

  • showforms – Lists the forms on the page and the fields within each.

  • showlinks – Lists the links on the page.

  • show – Lists the source HTML from the page.

  • exit – Quits the twill-sh program.

Often the most convenient way to use twill-sh is to create a text file that contains your twill commands. You can then specify that file on the command line when you invoke twill-sh. This lets you analyze problems that occur.

Invoke twill-sh with a text file as such:

> PYTHONPATH=$ZENHOME/Products/ZenWebTx/lib
$ZENHOME/Products/ZenWebTx/bin/twill-sh -i myTwillCommands.txt

The -i option instructs twill-sh to stay in the twill shell rather than exiting when it finishes running the commands in the myTwillCommands.txt file.