Extensions
Every application has unique pieces, and we found that we wanted to add lots of functionality to windmill specifically for our application. As a result of this we are assuming that some of you would probably like to do the same.
Creating any new extension will be similar to the one I walk you through below, this one happens to be a mach assertion you might be wanting for you application.
The quick and dirty way to do this is by adding your functionality to the (extensions/extensions.js) file.
The second way is to create your own extensions folder somewhere on the file system and organize your extensions into .js files in this directory. You can then load them into the IDE using the shell command, load_extensions_dir('path/to/extensions/dir') and every extension in the directory will be loaded into the Windmill IDE. This makes it easy to check your extensions specific to your app into a source repository and be automatically loaded before you run your tests in the setup method for the __init__.py in the root of your test directory.
You can also pass the path to your extensions to windmill when you start the server, and as soon as the IDE is available the extensions will be loaded, ex: windmill shell firefox extensions=/path/to/ext tests=/path/to/tests http://www.example.com
An example of an assertion called assertSomething:
//Please give a brief description of the assertion
//The param_object is passed to every controller function
windmill.controller.extensions.assertSomething = function (param_object) {
//You usually need to look up a UI element, this will use any provided locator
//And return you an element
var element = this._lookupDispatch(param_object);
//If the element was found error
if (!element){
return false;
}
//--Your application Logic should probably go here--
//Else return true
return true;
};
windmill.registry.methods['extensions.assertSomething'] = {'locator': true, 'option': true };
If you would like to use another option other than validator to pass data to your assertion you can add it with:
windmill.registry.option.push("my_new_option");
Now give it a try by either building your assertion in the IDE, or with JSON: {"method": "assertSomething", "params": {"id" : "whatever", "validator" : "blah"}}
