Run Selenium test suites from within Zope2
This product allows developers to create TTW Selenium test suites inside their Zope instance, in order to do browser-based functional testing of their site.
If you’re using buildout, add Products.Zelenium to the eggs = parameter of the instance part.
If using the virtualenv approach to developing Zope2 software, add Products.Zelenium to the install_requires parameter in the setup.py of your package or just run bin/easy_install Products.Zelenium after installing Zope2.
Finally, if you’re using the traditional INSTANCE_HOME installation:
- Unpack the tarball in a temporary location.
- Copy or move the Zelenium directory to the Products directory of your INSTANCE_HOME.
- Restart Zope.
You can add a Zuite object at any location within your Zope site. It behaves as a standard ordered folder, with a couple of differences:
Please use Launchpad to report bugs you find against the product, as well as to submit patches, request features, etc.
Tests are just File instances whose names begin with test. They should have a content type of text/html, and should contain a table which defines the steps which make up the test case.
See http://selenium.thoughtworks.com/testrunner.html for documentation on the table structure and the Selenese language.
On the “Properties” tab of your test suite, you can add / modify the list of meta_types which the suite will allow as test cases. Adding “Script (Python)”, for instance, allows you to define test cases in PythonScripts.
Each test suite automatically includes the test cases of any suite it contains. You can take advantage of this feature to organize your test cases in a hierarchy, running them in separate segments, or all at once.
Test suites now have a property, filesystem_path; if set, the suite will recursively load testcases from files in / under the directory pointed to by that path.
The list of files to be included is computed via the following rules:
On the “Zip” tab, supply a filename and click the “Download” button. The Zuite object will construct a zip file with the following contents:
The archive will also contain each of the supporting .js and .css files which drive the browserbot.
On the “Zip” tab, supply a filename and click the “Download” button. The Zuite object will construct a zip file with the same contents described above, and then save it as a File object in its own contents.
Download the tcpwatch product from Shane Hathaway’s site:
Unpack and run tcpwatch in its “HTTP proxy” mode, with recoring turned on. E.g., the following command runs the proxy on port 9999, recording the request / response data to the directory /tmp/recorded_scenario:
$ python /path/to/tcpwatch/ tcpwatch.py \ -p 9999 -r /tmp/recorded_scenario
Configure your browser to use an HTTP proxy on localhost, port 9999.
Click through your site, exercising the features you are testing.
Stop the proxy. Run the generator.py script, pointing to the directory where tcpwatch was recording:
$ python /path/to/Zelenium/generator.py \ --logfile-directory=/tmp/recorded_scenario \ --output-file=test_case_name.html
Edit the generated test case, removing / correcting the various steps.
Upload the test case to a Zelenium Zuite and run it.
Selenium has a feature which allows the testrunner to upload result data from an automated test run to the server.
Invoke the test suite from your browser as usual, but append the query string ?auto=true, to the URL, e.g.:
Selenium will run all test cases, and then upload its result data to the postResults method of your suite. (Note that you no longer need the postResults PythonScript in the root of your site, because the latest version of Selenium posts to that name relative to the test suite).
The semantics of click have changed; that command no longer waits by default, and the nowait modifier is no longer meaningful. Use clickAndWait to get the desired semantics.
Add ability to suppress inclusion of Selenium support files in snapshot / download.
Add support for returning testcases from a mapped directory path, including recursion through subdirectories of that path. Currently, the implementation has the following issues:
Add unit tests for Zuite.__getitem__ behavior, including support files.
Make Zuite instances recursively include their Zuite children’s test cases (to allow easier organization of the test cases in a hierarchy).
Allow indiviual zuites to override the list of metatypes which can be test cases, via a new testcase_metatypes property.
Force Zuite objects to show order support, even in the presence of ExternalEditor, whose monkey patching seems to trip it up. Surface the EE icon, if the product is available
Note: we are forking OFS/dtml/main.dtml and the version in ExteranalEditor/manage_main.dtml to surface order support, which is a pretty brutal hack. We should probably get ExteranalEditor fixed, instead, and rip out the forked copy.