Getting Started

adiroiban edited this page Apr 15, 2011 · 7 revisions

Running Windmill

Windmill has to provide a few different ways to run. Windmill tries to provide some environments that make debugging easier depending on what your regular test authoring and debugging style is.

Command Line Utility

First, let’s look at the windmill command line usage output.

windmill web test automation system.
    windmill [-cdelptmxs] action [option=value] [firefox|ie|safari] [http://www.example.com]

Available Actions:
    shell         Enter the windmill shell environment (modified python shell). 
                  Uses ipython if installed. Exit using ^d
    run_service   Run the windmill service in foreground. Kill using ^c.

Available Options:
    browserdebug :: Enable browser debugging. 
        Python tests will all load in to the server at once. Defaults to False
    -c, continueonfailure :: Keep the browser running tests after failure. Defaults to False
    -d, debug :: Turn on debugging.
    -e, exit :: Exit after all tests have run. Defaults to False
    extensions=FOLDER.  :: The directory containing any windmill javascript extensions.
    firebug :: Install Full Firebug. Firefox only!
    jsdir=FOLDER.  :: JavaScript Test Framework : 
        Root directory of JavaScript tests.
    jsfilter=FILTER.  :: JavaScript Test Framework : 
        Filter tests, example; ns:test_login,tests:test_user.
    jsphase=PHASE.  :: JavaScript Test Framework : 
        Specify the phases the framework should run example; setup,test,teardown
    -l, loadtest=FILE_OR_FOLDER.  :: Run the given test file/dir
    loglevel=LEVEL.  :: Log level command, sets the global logging level.
    nocompress :: Do not compress windmill javascript files. Defaults to False
    -p, pdb :: Enable pdb debugging when running python tests. Defaults to False
    port=PORT_NUMBER.  :: Set port for windmill to run. Default is 4444.
    -t, test=FILE_OR_FOLDER.  :: Run the given test file/dir
    ssl :: Enable SSL support.
    chrome :: Start the Chrome browser. Windows Only. Defaults to False
    -m, firefox :: Start the firefox browser. Defaults to False
    -x, ie :: Start the internet explorer browser. Windows Only. Defaults to False
    -s, safari :: Start the Safari browser. Defaults to False
    usecode :: Use the code module rather than ipython. Defaults to False

Actions

The Available Actions denote that available environments windmill can start up.

The ’’shell’’ environment will start windmill and drop in to a python shell. The shell has various objects and functions in the local scope to help you with debugging and running tests.

The ’’run_service’’ environment just runs windmill in the foreground until it gets a proper signal to end. This is good for continuous integration and for someone who wishes to just run tests without the need for debugging.

The ’’wx’’ environment will launch our experimental wxPython UI for the service. This UI is still under heavy development and have some limitations and rough edges. We hope in the future to make this the default environment for windmill.

Browsers and URLs

The windmill binary can take an argument for the browser you would like to launch on startup. Although the shell has specific commands for launching the browser it’s a matter of necessity that this be available as a command line option to the other actions, and a matter of convenience when starting the shell.

Windmill also takes the URL for the web page you would like to begin testing. Although windmill starts without this option you may find that you can run things much smoother if you include it. More on this in CrossDomainTesting (TBD).

windmill firefox http://www.example.com

The Shell Environment

Ok, let’s start the windmill shell.

windmill shell http://www.example.com

  • A quick divergence to talk about ipython.
  • If you are new to python it is strongly suggested that you install and use ipython. ipython has lot’s of handy object introspection and command history features that will make your life easier. We’ve tried to make it as easy as possibly for anyone to use and debug in windmill and we don’t think that you need to know python to use the shell environment and ipython makes this much easier.
  • If you have ipython installed windmill will use that as it’s shell environment rather than the regular python shell available in the ’’code’’ module. If you have ipython installed but you want to use the regular python shell instead you can give windmill the ’’usecode’’ option.
  • Pre-compiled binaries should ship with ipython.
  • The rest of this section will assume you are using ipython.

Back to using the shell environment.

After starting the shell environment you’ll notice an interesting prompt.

In [1]:

From here you can use any of the ’’objects’’ that windmill automatically gives you in the shell. You can see a list of these objects by typing dir() in the shell.

[
... 
 'clear_queue',
 'frame',
 'help',
 'httpd',
 'httpd_thread',
 'jsonrpc_client',
 'load_test',
 'logger',
 'logging',
 'os',
 'run_test',
 'show_queue',
 'sleep',
 'start_firefox',
 'start_ie',
 'start_safari',
 'sys',
 'windmill',
 'xmlrpc_client']

Most of these objects are just functions that you can call. If you want to find out more about a specific object just type ? at the end and ipython will inspect the object and tell you more about it.

In [2]: start_firefox?
Type:           function
Base Class:     <type 'function'>
String Form:    <function start_firefox at 0x172ed30>
Namespace:      Interactive
File:           /Users/mikeal/Documents/projects/windmill/trunk/windmill/bin/shell_objects.py
Definition:     start_firefox()
Docstring:
    Start the Firefox web browser configured for windmill
Class Docstring:
    function(code, globals[, name[, argdefs[, closure]]])

    Create a function object from a code object and a dictionary.
    The optional name string overrides the name from the code object.
    The optional argdefs tuple specifies the default argument values.
    The optional closure tuple supplies the bindings for free variables.
Constructor Docstring:
    x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Callable:       Yes
Call def:       Calling definition not available.Call docstring:
    x.__call__(...) <h2. > x(...)

If you want to use this function and start the firefox browser;

In [3]: start_firefox()