Package: rcom.recipe.seleniumenv
ContentsDetailed DocumentationSupported optionsExample usageThe seleniumrunner scriptRunning the testsCreating a testTests development guidelinesExample testContributorsChange history0.1 (2009-01-05)1.0 (2009-02-14)DownloadCode repository:http://svn.rcom.com.ar/rcom.recipe.seleniumenvQuestions and comments to santiycr at rcom dot com dot arReport bugs at santiycr at rcom dot com dot arDetailed DocumentationWatch the screencast!Supported optionsThe recipe supports the following options:seleniumversionThe version of selenium to use, the version numbers can be taken fromhttp://release.seleniumhq.org/selenium-remote-control/. Default: nightlyBuild.eggsThe eggs to include in the runner path. Any product included in the path will be
accessible for the runner to search and run selenium tests from.java-cmdThe command used to run the selenium server. Default: java.Example usageThe basic buildout that uses the recipe should look like the following:>>> write('buildout.cfg',
... """
... [buildout]
... parts = seleniumenv
...
... [seleniumenv]
... recipe = rcom.recipe.seleniumenv
... seleniumversion = 1.0-beta-2
... eggs = ${instance:eggs}The seleniumrunner scriptThe selenium runner is a script to find and runselenium tests, it will
be on your bin directory once the recipe is installed
It receives different parameters and it’s main objective is to simplify the
tests execution and reporting procedure.
This script will wake-up the selenium RC server, search and run the tests
and then shutdown the server and report the tests result.
Once the recipe has been installed, a tests runner should be placed on the bin
directoryRunning the testsTo run the suite of tests bundled with any product, the first thing to do after
the buildout has been run is to prepare a Plone site to test (if the user
doesn’t have a Plone site to test, yet).
For this to be done, you must first wake up the instance:./bin/instance startTo run all the selenium tests for a product the user should pass at least two
parameters:-iinstanceThe Plone site’s name.-sproductThe product in which the runner will search for tests to run.An example test execution will be:$ ./bin/seleniumrunner -i testPloneSite -s namespace.productThis will search all theseleniumtests for the product and run them
onhttp://localhost:<port_used>/testPloneSite.For running  a particular test, the -t parameter should be passed to the runner:$ ./bin/seleniumrunner -i testPloneSite -s namespace.product -t exampleTestNotePlease notice that the exampleTest.py test should be stored in the
respective location and added to the __init__py file (SeeCreating a test)Creating a testThe seleniumrunner script will look for all the classes that inherit from
unittest.TestCase on a specified package or module located under this kind of
path:namespace.product/namespace/product/tests/seleniumtestsTests development guidelinesTo create a test, there are certain basic rules to follow:The test should inherit from unittest.TestCase class (this can be done
indirectly also).The test should use certain global variables for the code to work
on different environments and Plone instances. These are:browser: For the browser used for the testsport: For the port used to communicate with the serverurl: For the url of the application under testinstance: The Plone site name (this depends on
the name used for the site’s creation).This variables should never be changed inside the test code, as the
seleniumrunner script will set them at runtime according with the parameters
received.All this rules can be seen applied to the followingExample test.Example testThe following is an example test, it can be used as the basic
structure for future tests:from selenium import selenium
import unittest

class NewTest(unittest.TestCase):
    def setUp(self):
        self.verificationErrors = []
        self.selenium = selenium("localhost", port, browser, url)
        self.selenium.start()

    def test_new(self):
        sel = self.selenium
                        sel.open(instance + "/login.html")
        # Do specific tests in here

    def tearDown(self):
        self.selenium.stop()
        self.assertEqual([], self.verificationErrors)Notice that the test doesn’t have much changes from the basic test exported usingSelenium IDE, the firefox extension. The
only difference are the variables used for the instantiation inside thesetUpmethod.NotePlease notice that the “instance” variable will have to be used in
eachopencommand for the users to provide the correct location
of the plone site to test.ContributorsSantiago Suarez Ordoñez, Author
Juan Pablo Gimenez, ContributorChange history0.1 (2009-01-05)Created recipe with ZopeSkel [Santiago Suarez Ordoñez].1.0 (2009-02-14)Ended code changes and uploaded the egg to pypi [Santiago Suarez Ordoñez].Downloadhttp://pypi.python.org/packages/source/r/rcom.recipe.seleniumenv/rcom.recipe.seleniumenv-1.0dev-r4475.tar.gz#md5=a093a67c7fe5d9339856e0ebda88061e