Permalink
Browse files

Use the Selenium 2 web driver. This removes the need to download any jar

files or run any Java since the web driver installs an extension into any
given browser to run tests.

svn path=/plone.app.testing/trunk/; revision=40956
  • Loading branch information...
1 parent e14df3a commit 7a8a9eb7fd23ee5cd46e51e59c389b3c51766bb7 @rpatterson rpatterson committed Oct 30, 2010
Showing with 17 additions and 51 deletions.
  1. +6 −0 buildout.cfg
  2. +4 −1 plone/app/testing/selenium.txt
  3. +7 −22 plone/app/testing/selenium_layers.py
  4. +0 −28 selenium.cfg
View
@@ -10,6 +10,12 @@ eggs =
PILwoTk
plone.app.testing [test]
defaults = ['--auto-color', '--auto-progress', '--verbose']
+environment = testenv
+
+[testenv]
+## Uncomment one of the following to test against a browser other than firefox
+#SELENIUM_DRIVER = ie
+#SELENIUM_DRIVER = chrome
[coverage-report]
recipe = zc.recipe.egg
@@ -104,4 +104,7 @@ When the layer is torn down, the Selenium browser is closed.
Tear down plone.testing.z2.Startup in ... seconds.
Tear down plone.testing.zca.LayerCleanup in ... seconds.
- >>> case.selenium.sessionId
+ >>> from selenium.remote.webdriver import WebDriver as RemoteWebDriver
+ >>> RemoteWebDriver._execute(case.selenium, 'quit')
+ Traceback (most recent call last):
+ URLError: <urlopen error [Errno 111] Connection refused>
@@ -1,10 +1,8 @@
-import selenium
import os
import transaction
import unittest2 as unittest
from plone.app.testing import PloneSandboxLayer
-from plone.app.testing import PLONE_SITE_ID
from plone.app.testing import FunctionalTesting
from plone.app.testing.layers import PLONE_FIXTURE
from plone.testing import z2
@@ -13,20 +11,15 @@
class SeleniumLayer(PloneSandboxLayer):
defaultBases = (z2.ZSERVER_FIXTURE, PLONE_FIXTURE)
- # Connection parameters
- seleniumHost = os.environ.get('SELENIUM_HOST', 'localhost')
- seleniumPort = os.environ.get('SELENIUM_PORT', '4444')
- seleniumBrowser = os.environ.get('SELENIUM_BROWSER', '*firefox')
-
def setUpPloneSite(self, portal):
# Start up Selenium
- url = "http://%s:%s/%s" % (self['host'], self['port'], PLONE_SITE_ID)
- self['selenium'] = selenium.selenium(
- self.seleniumHost, self.seleniumPort, self.seleniumBrowser, url)
- self['selenium'].start()
+ driver = os.environ.get('SELENIUM_DRIVER', 'firefox')
+ webdriver = __import__(
+ 'selenium.%s.webdriver' % driver, fromlist=['WebDriver'])
+ self['selenium'] = webdriver.WebDriver()
def tearDownPloneSite(self, portal):
- self['selenium'].stop()
+ self['selenium'].quit()
del self['selenium']
SELENIUM_FIXTURE = SeleniumLayer()
@@ -40,15 +33,7 @@ class SeleniumTestCase(unittest.TestCase):
def setUp(self):
self.selenium = self.layer['selenium']
- def open(self, path="/", site_name=PLONE_SITE_ID):
+ def open(self, url):
# ensure we have a clean starting point
transaction.commit()
- self.selenium.open("/%s/%s" % (site_name, path,))
-
- def wait(self, timeout="30000"):
- self.selenium.wait_for_page_to_load(timeout)
-
- def waitForElement(self, selector, timeout="30000"):
- """Continue checking for the element matching the provided CSS
- selector."""
- self.selenium.wait_for_condition("""css="%s" """ % selector, timeout)
+ self.selenium.get(url)
View
@@ -1,28 +0,0 @@
-[buildout]
-extends = buildout.cfg
-parts +=
- selenium-build
- selenium
-
-[selenium-build]
-recipe = hexagonit.recipe.download
-version = 2.0a7
-url = http://selenium.googlecode.com/files/selenium-server-${selenium-build:version}.zip
-strip-top-level-dir = True
-
-[selenium]
-recipe = zc.recipe.egg:scripts
-entry-points = selenium-server=sys:exit
-initialization =
- import subprocess
- retcode = subprocess.call(['java', '-jar',
- '${selenium-build:location}/selenium-server-standalone-${selenium-build:version}.jar'])
-arguments = retcode
-
-[test]
-environment = testenv
-
-[testenv]
-## Uncomment and modify the following to test against a Selenium Grid
-#SELENIUM_HOST = some.grid.ip
-#SELENIUM_PORT = some_grid_port

0 comments on commit 7a8a9eb

Please sign in to comment.