| 1 | Metadata-Version: 1.0 |
|---|
| 2 | Name: rcom.recipe.seleniumenv |
|---|
| 3 | Version: 1.0dev-r258 |
|---|
| 4 | Summary: A recipe for setting a ready-to-use selenium RC environment |
|---|
| 5 | Home-page: www.rcom.com.ar |
|---|
| 6 | Author: Santiago Suarez Ordonez |
|---|
| 7 | Author-email: santiycr@rcom.com.ar |
|---|
| 8 | License: ZPL |
|---|
| 9 | Description: .. contents:: |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | - Code repository: http://svn.rcom.com.ar/rcom.recipe.seleniumenv |
|---|
| 13 | - Questions and comments to santiycr atrcom dotcom dotar |
|---|
| 14 | - Report bugs at santiycr atrcom dotcom dotar |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | Detailed Documentation |
|---|
| 18 | ********************** |
|---|
| 19 | |
|---|
| 20 | Supported options |
|---|
| 21 | ================= |
|---|
| 22 | |
|---|
| 23 | The recipe supports the following options: |
|---|
| 24 | |
|---|
| 25 | seleniumversion |
|---|
| 26 | The version of selenium to use, the version numbers can be taken from |
|---|
| 27 | http://release.seleniumhq.org/selenium-remote-control/. Default: nightlyBuild. |
|---|
| 28 | |
|---|
| 29 | eggs |
|---|
| 30 | The eggs to include in the runner path. Any product included in the path will be |
|---|
| 31 | accesible for the runner to search and run selenium tests from. |
|---|
| 32 | |
|---|
| 33 | java-cmd |
|---|
| 34 | The commando used to run the selenium server. Default: java. |
|---|
| 35 | |
|---|
| 36 | Example usage |
|---|
| 37 | ============= |
|---|
| 38 | |
|---|
| 39 | The basic buildout that uses the recipe should look like the following:: |
|---|
| 40 | |
|---|
| 41 | >>> write('buildout.cfg', |
|---|
| 42 | ... """ |
|---|
| 43 | ... [buildout] |
|---|
| 44 | ... parts = seleniumenv |
|---|
| 45 | ... |
|---|
| 46 | ... [seleniumenv] |
|---|
| 47 | ... recipe = rcom.recipe.seleniumenv |
|---|
| 48 | ... seleniumversion = 1.0-beta-2 |
|---|
| 49 | ... eggs = ${instance:eggs} |
|---|
| 50 | |
|---|
| 51 | |
|---|
| 52 | The seleniumrunner script |
|---|
| 53 | ========================= |
|---|
| 54 | |
|---|
| 55 | The selenium runner is a scipt to find and run **selenium tests**, it will |
|---|
| 56 | be on your bin directory once the recipe is instanlled |
|---|
| 57 | It receives different parameters and it's main objective is to simplify the |
|---|
| 58 | tests execution and reporting procedure. |
|---|
| 59 | This script will wake-up the selenium RC server, search and run the tests |
|---|
| 60 | and then shutdown the server and report the tests result. |
|---|
| 61 | Once the recipe has been installed, a tests runner should be placed on the bin directory |
|---|
| 62 | |
|---|
| 63 | Running the tests |
|---|
| 64 | ----------------- |
|---|
| 65 | |
|---|
| 66 | To run the suite of tests buldled with any product, the first thing to do after |
|---|
| 67 | the buildout has been run is to prepare a Plone site to test (if the user doesn't |
|---|
| 68 | have a Plone site to test, yet). |
|---|
| 69 | For this to be done, you must first wake up the instance:: |
|---|
| 70 | |
|---|
| 71 | ./bin/instance start |
|---|
| 72 | |
|---|
| 73 | To run all the selenium tests for a product the user should pass at least two |
|---|
| 74 | parameters: |
|---|
| 75 | |
|---|
| 76 | -i instance |
|---|
| 77 | The Plone site's name. |
|---|
| 78 | |
|---|
| 79 | -s product |
|---|
| 80 | The product in which the runner will search for tests to run. |
|---|
| 81 | |
|---|
| 82 | An example test execution will be:: |
|---|
| 83 | |
|---|
| 84 | $ ./bin/seleniumrunner -i testPloneSite -s namespace.product |
|---|
| 85 | |
|---|
| 86 | This will search all the **selenium** tests for the product and run them |
|---|
| 87 | on http://localhost:<port_used>/testPloneSite. |
|---|
| 88 | |
|---|
| 89 | For running a particular test, the -t parameter should be passed to the runner:: |
|---|
| 90 | |
|---|
| 91 | $ ./bin/seleniumrunner -i testPloneSite -s namespace.product -t exampleTest |
|---|
| 92 | |
|---|
| 93 | .. Note:: |
|---|
| 94 | |
|---|
| 95 | Please notice that the exampleTest.py test should be stored in the |
|---|
| 96 | respective location and added to the __init__py file (See `Creating a test`_) |
|---|
| 97 | |
|---|
| 98 | Creating a test |
|---|
| 99 | --------------- |
|---|
| 100 | |
|---|
| 101 | The seleniumrunner script will look for all the classes that inherit from |
|---|
| 102 | unittest.TestCase on a specified package or module located under this kind of |
|---|
| 103 | path:: |
|---|
| 104 | |
|---|
| 105 | namespace.product/namespace/product/tests/seleniumtests |
|---|
| 106 | |
|---|
| 107 | Tests development guidelines |
|---|
| 108 | ++++++++++++++++++++++++++++ |
|---|
| 109 | |
|---|
| 110 | To create a test, there are certain basic rules to follow: |
|---|
| 111 | |
|---|
| 112 | #) The test should inherit from unittest.TestCase class (this can be done |
|---|
| 113 | indirectly also). |
|---|
| 114 | #) The test should use certain global variables for the code to work |
|---|
| 115 | on different environments and Plone instances. These are: |
|---|
| 116 | |
|---|
| 117 | - browser: For the browser used for the tests |
|---|
| 118 | |
|---|
| 119 | - port: For the port used to communicate with the server |
|---|
| 120 | |
|---|
| 121 | - url: For the url of the application under test |
|---|
| 122 | |
|---|
| 123 | - instance: The Plone site name (this depends on |
|---|
| 124 | the name used for the site's creation). |
|---|
| 125 | |
|---|
| 126 | This variables should never be changed inside the test code, as the |
|---|
| 127 | seleniumrunner script will set them at runtime according with the parameters |
|---|
| 128 | received. |
|---|
| 129 | |
|---|
| 130 | All this rules can be seen applied to the following `Example test`_. |
|---|
| 131 | |
|---|
| 132 | Example test |
|---|
| 133 | ++++++++++++ |
|---|
| 134 | |
|---|
| 135 | The following is an example test, it can be used as the basic |
|---|
| 136 | structure for future tests:: |
|---|
| 137 | |
|---|
| 138 | from selenium import selenium |
|---|
| 139 | import unittest |
|---|
| 140 | |
|---|
| 141 | class NewTest(unittest.TestCase): |
|---|
| 142 | def setUp(self): |
|---|
| 143 | self.verificationErrors = [] |
|---|
| 144 | self.selenium = selenium("localhost", port, browser, url) |
|---|
| 145 | self.selenium.start() |
|---|
| 146 | |
|---|
| 147 | def test_new(self): |
|---|
| 148 | sel = self.selenium |
|---|
| 149 | sel.open(instance + "/login.html") |
|---|
| 150 | # Do specific tests in here |
|---|
| 151 | |
|---|
| 152 | def tearDown(self): |
|---|
| 153 | self.selenium.stop() |
|---|
| 154 | self.assertEqual([], self.verificationErrors) |
|---|
| 155 | |
|---|
| 156 | Notice that the test doesn't have much changes from the basic test exported using |
|---|
| 157 | `Selenium IDE <http://seleniumhq.org/projects/ide/>`_, the firefox extension. The |
|---|
| 158 | only difference are the variables used for the instanciation inside the *setUp* method. |
|---|
| 159 | |
|---|
| 160 | .. Note:: |
|---|
| 161 | |
|---|
| 162 | Please notice that the "instance" variable will have to be used in |
|---|
| 163 | each *open* command for the users to provide the correct location |
|---|
| 164 | of the eduCommons plone site to test. |
|---|
| 165 | |
|---|
| 166 | Contributors |
|---|
| 167 | ************ |
|---|
| 168 | |
|---|
| 169 | Santiago Suarez Ordonez, Author |
|---|
| 170 | Juan Pablo Gimenez, Contributor |
|---|
| 171 | |
|---|
| 172 | Change history |
|---|
| 173 | ************** |
|---|
| 174 | |
|---|
| 175 | 0.1 (2009-01-05) |
|---|
| 176 | ================== |
|---|
| 177 | - Created recipe with ZopeSkel [Santiago Suarez Ordonez]. |
|---|
| 178 | |
|---|
| 179 | 1.0 (2009-02-14) |
|---|
| 180 | ================== |
|---|
| 181 | - Ended code changes and uploaded the egg to pypi [Santiago Suarez Ordonez]. |
|---|
| 182 | |
|---|
| 183 | Download |
|---|
| 184 | ******** |
|---|
| 185 | |
|---|
| 186 | Keywords: selenium rc testing plone ajax recipe |
|---|
| 187 | Platform: UNKNOWN |
|---|
| 188 | Classifier: Framework :: Buildout |
|---|
| 189 | Classifier: Intended Audience :: Developers |
|---|
| 190 | Classifier: Topic :: Software Development :: Build Tools |
|---|
| 191 | Classifier: Topic :: Software Development :: Libraries :: Python Modules |
|---|
| 192 | Classifier: License :: OSI Approved :: Zope Public License |
|---|