Here is what they can do:
- Launch any Mozilla application: Firefox, Thunderbird and any xulrunner app,
- Use an empty profile for each test execution, or an existing one,
- Speak fluently "assert" language: isTrue, isFalse, isDefined, equals, ... etc,
- Report you in real time test execution directly in your test source code,
- They are always ready to work. You don't need to restart Freemonkeys on each test execution, nor on your application reboot. Freemonkeys is an independant xulrunner app, which launch yours and then controls it remotly with a network connexion,
- Spot easily any window, any tab and any DOM element with usefull distinctive parameters: XPath, windows attributes, zIndex order, ... etc,
- Offer a way to facilitate node identification by simply clicking on it, and seeing in real time what are selected node parameters,
- They are able to write down some debug messages, inspect javascript objects with DOM Inspector, take screenshots of any elements,
- Ease you some kind of tests, by providing you a simple HTTP webserver in order to simulate some websites answers,
- They are not narrow-minded to synchronous tests but offers an assert library and some usefull API embracing asynchronous execution of your code!
Now let's highlight some of these cool features ...
Node selection
Here I was overing the tip of the day image. Freemonkeys spot it by highlighting it in red and show me all parameters which are going to be used to find this node later:You just have to click on it to get back to test editor and have all javascript code needed to get a reference to this node, something like this:
var top = windows.getRegistered("firefox-window", "topmost"); var tab = top.tabs.current; var element = elements.xpath(tab, "id('frame')/tbody[1]/tr[5]/td[1]/table[1]/tbody[1]/tr[1]/td[1]/table[1]/tbody[1]/tr[1]/td[1]/img[1]");
Elements screenshots
Simply write:
element.screenshot();And get a screenshot directly in the test editor:
Live test execution reporting
Your monkeys report each assert status in the test editor, allowing you to keep the focus on test writing and not losing time by switching from your app to your terminal, then to your code editor, your terminal and your app ... etc, etc.
HTTP API
// Get a reference to a firefox tab var top = windows.getRegistered("firefox-window", "topmost"); var tab = top.tabs.current;// Start an HTTP server on port 81 http.start("81");
// A successfull test // Create an assert objet which is going to wait for a request on root path of our http server var test = http.assertGetRequest("/"); // Open this page in the tab tab.open("http://localhost:81/"); // Now wait for this request test.wait();
// The same test but with a non-existant page on our local server, so a failing test! var test = http.assertGetRequest("/"); tab.open("http://localhost:81/foo"); test.wait();
Asynchronous tests
// A usefull function which allow you to block test execution for an amount of time in ms wait.during(1000);// The simpliest asynchronous test wait.forTrue(function () { return true; });
// Another, which is going to pass after 3s, with this setTimeout var v=true; wait.setTimeout(function() { v=false; },3000); wait.forFalse(function () { return v; });
// Finally, a test which will pass when the test function is going to be called ten times // (wait for the anonymous function returns 10) var i=0; wait.forEquals(function () { return i++;; }, 10);
How to get it ?
Source code is available on github: http://github.com/ochameau/freemonkeys (LGPL licence)If you are on windows:
- Download this package: freemonkeys-0.1-win.zip
- Extract this zip file somewhere
- Launch freemonkeys.exe
- Download this one: freemonkeys-0.1.zip
- Extract it somewhere
- If you don't have xulrunner, download it from here
- Finally, launch Freemonkeys with this command:
/path/to/your/xulrunner/dir/xulrunner /path/to/freemonkeys/application.ini
Comments
You can use your Fediverse (i.e. Mastodon, among many others) account to reply to this post
(Note that comments from locked accounts won't be visible on the blog, but only to me)