Skip to main content

Run Selenium test suites from within Zope2

Project description

Zelenium: Selenium Tests on Zope2

Overview

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.

Prerequisites

Installing the Product

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:

  1. Unpack the tarball in a temporary location.

  2. Copy or move the Zelenium directory to the Products directory of your INSTANCE_HOME.

  3. Restart Zope.

Using Zelenium

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:

  • It’s index_html is the “TestRunner.html” view familiar from Selenium.

  • It derives the test suite (in the upper left corner iframe) from all OFS.Image.File objects whose names start with test. You can use the OrderedFolder support to modify the order in which the test case files are run.

  • It provides a “Zip” action, which allows you to export the test suite, all test cases, and the supporting Selenium Javascript / CSS files as a single, self-contained zipfile.

Reporting Bugs against Zelenium

Please use Launchpad to report bugs you find against the product, as well as to submit patches, request features, etc.

Adding Tests

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.

Using Additional Metatypes as Test Cases

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.

Nesting Test Suites

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.

Including Tests from the Filesystem

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:

  • If the testsuite_name property contains the name of a file that exists in the directory, it is presumed to contain a list of files containing tests, one per line. The test cases will be presented in the order indicated in the file, and test cases may be included more than once.

  • If the testsuite_name property is empty but the directory contains a file, .objects, it is presumed to contain a list of files to be included, one per line; only those files / subdirectories (if present) will be included. In this case, the test cases will be presented in the order indicated in the file, followed by any test cases from subdirectories.

  • Otherwise, if the suite’s property, filename_glob is non-empty, it will be expanded (via Python’s glob.glob) to compute the list of filenames. The test cases will be presented in alphabetical order, followed by any test cases from subdirectories.

  • Otherwise, any file will be considered a testcase. The test cases will be presented in alphabetical order, followed by any test cases from subdirectories.

Exporting an Archive

On the “Zip” tab, supply a filename and click the “Download” button. The Zuite object will construct a zip file with the following contents:

index.html

the “TestRunner.html” framework page

TestSuite.html

the list of test case files (rendered as static HTML)

test*

your test case files (appending .html if the IDs do not have extensions)

The archive will also contain each of the supporting .js and .css files which drive the browserbot.

Creating a Snapshot

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.

Generating Testcases using tcpwatch

  1. Download the tcpwatch product from Shane Hathaway’s site:

    http://hathawaymix.org/Software/TCPWatch

  2. 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
  3. Configure your browser to use an HTTP proxy on localhost, port 9999.

  4. Click through your site, exercising the features you are testing.

  5. 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
  6. Edit the generated test case, removing / correcting the various steps.

  7. Upload the test case to a Zelenium Zuite and run it.

Capturing Results from the Test Run

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.:

http://localhost:8080/test_suite?auto=true

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).

Zelenium Product Changelog

1.0.3 (2010-11-10)

  • Remove setuptools_bzr requirement, since that package was causing installs to break. Instead, add a replacement sdist command which aborts if setuptools_bzr cannot be imported.

1.0.2 (2010-05-05)

  • Add setuptools_bzr as a setup requirement to avoid future brown-bag releases.

  • Fix rendering of results views which contain non-ASCI text. Thanks to Leo Rochael for the test and the fix. Fixes lp:575415.

  • Updated README to indicate Zope2 prerequisite, and point to its installation documentation.

1.0.1 (2010-04-07)

  • Packaging update only, fixin brown-bag release (minus metadata files). Also, note move of bug tracker from www.zope.org to Launchpad.

1.0 (2010-04-07)

  • Eggified, tested and removed deprecations under Zope 2.12.

  • Moved from svn.zope.org to Launchpad.

  • Updated included selenium to selenium-core 0.8.3.

  • Applied a fix from Rob Miller to make Zelenium Zuite objects functional in the presence of five:traverse, making index_html the explicit default view.

  • Corrected the documentation in the README for capturing results of a test run (auto=1 -> auto=true, in line with the Selenium documentation). Thanks to Yoshinori Okuji for pointing this out.

0.8 (2006/05/16)

  • Fixed unit tests by wrapping filesystem objects that are rendered during ZIP file creation - code in OFS.Image wants to acquire REQUEST and use RESPONSE.

  • Found how to make the dependency on ExternalEditor optional (thanks to Andreas Jung for the bug report).

  • Stripped empty filenames out of manifest, to avoid infinite recursion.

  • Added the testsuite_name property that allows multiple test suites to be built up from test cases within a single filesystem directory.

  • Upgrade to selenium version 0.6

  • Suites now recurse through all “folderish” subobjects, looking for tests (allows, for instance, tests to be loaded from disk via CMF’s FileSystemDirectoryView). Thanks to Malcom Cleaton for the patch!

  • Define zelenium_globals in __init__.py to be able to register the selenium directory for use as a CMF skin directory.

  • If debug-mode is set to “on” in zope.conf, filesystem-based testcases files are reloaded every time they are used, to ease development of filesystem-based test suites. This behavior emulates what the CMF Filesystem Directory Views do with debug-mode on.

  • Moved repository to Subversion: svn+ssh://svn.zope.org/repos/main/Zelenium/

0.7 (2005/06/07)

0.6 (2005/05/09)

  • 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:

    o It only creates OFS.Image.File objects for test cases (no templates,

    scripts, etc.)

  • Add unit tests for Zuite.__getitem__ behavior, including support files.

0.5.1 (2005/05/07)

  • Make passing / failing test cases in results view more obvious in printed representation by adding icons. N.B.: at the moment, we do this by sniffing the HTML of the test case for the “pink” backgrounds.

  • Apply patch from the selenium-devel list to fix regression in testcase HTML extraction in postTestResults.

  • Make the posted results folder into its own class, derived from Folder (moving the template out to a PageTemplateFile).

  • Further repaired recursive ZIPfile generation, including normalizing URLs in generated HTML.

  • Extended zuite unittests to test listTestCases and manage_createSnapshot, as well as recursive ZIPfile generation.

0.5 (2005/05/04)

0.4.1 (2005/05/02)

  • Repair breakage of ExternalEditor link in manage_main.

  • Compensate in display of test tables for non-padded integers in the IDs (make them sort properly).

0.4 (2005/04/27)

  • 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.

0.3.1 (2005/04/26)

  • Record server-side data during postResults: Zope version string, product names and versions.

  • Captured additional request parameters in postResults: user agent, HTTP host, remote address).

0.3 (2005/04/25)

  • Added postResults handling code to capture results as a sub- folder of the suite.

0.2.1 (2005/04/21)

  • Correct the emitted HTML for input widgets (close the tr tag).

  • Fix unpack bug in code which punts on requests to “foreign” hosts.

  • Punt on handling XML-RPC requests (e.g., Epoz calls back to the server to run Tidy).

0.2 (2005/04/20)

  • Added script, generator.py, to create Selenium testcase files from the request / response logfiles created by tcpwatch.

  • Allowed test cases to be PageTemplates, as well as Files, to permit indirecting through properties of the test suite (e.g., for user id / password).

0.1 (2005/04/15)

  • Initial release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Products.Zelenium-1.0.3.tar.gz (1.4 MB view details)

Uploaded Source

File details

Details for the file Products.Zelenium-1.0.3.tar.gz.

File metadata

File hashes

Hashes for Products.Zelenium-1.0.3.tar.gz
Algorithm Hash digest
SHA256 0d9bf56da0e63f8c5f25af919ad87c2cf718ceef59f92af7c526d12c2562e1b0
MD5 57e846e670c4ef139791a9bcbd51c240
BLAKE2b-256 d86fc1cadc9cc2e1edf887cc8a5c5b7990be3948b6b207fc2a6a874307abdadd

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page