[Checkins] SVN: gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/base.py Pick up environment variables in order to locate the selenium server, local application, browser and speed
Jan-Jaap Driessen
jdriessen at thehealthagency.com
Tue Nov 9 10:42:02 EST 2010
Log message for revision 118299:
Pick up environment variables in order to locate the selenium server, local application, browser and speed
Changed:
U gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/base.py
-=-
Modified: gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/base.py
===================================================================
--- gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/base.py 2010-11-09 15:40:45 UTC (rev 118298)
+++ gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/base.py 2010-11-09 15:42:01 UTC (rev 118299)
@@ -1,6 +1,6 @@
#############################################################################
#
-# Copyright (c) 2009 Zope Foundation and Contributors.
+# Copyright (c) 2010 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
@@ -11,23 +11,60 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
+import os
-import gocept.selenium.selenese
import selenium
+import gocept.selenium.selenese
+SELENIUM_SERVER_HOST_KEY = 'GOCEPT_SELENIUM_SERVER_HOST'
+SELENIUM_SERVER_HOST_DEFAULT = 'localhost'
+
+SELENIUM_SERVER_PORT_KEY = 'GOCEPT_SELENIUM_SERVER_PORT'
+SELENIUM_SERVER_PORT_DEFAULT = '4444'
+
+BROWSER_KEY = 'GOCEPT_SELENIUM_BROWSER'
+BROWSER_DEFAULT = '*firefox'
+
+APP_HOST_KEY = 'GOCEPT_SELENIUM_APP_HOST'
+APP_HOST_DEFAULT = '0.0.0.0'
+
+APP_PORT_KEY = 'GOCEPT_SELENIUM_APP_PORT'
+
+SPEED_KEY = 'GOCEPT_SELENIUM_SPEED'
+
+
+def _selenium_server_host():
+ return os.environ.get(SELENIUM_SERVER_HOST_KEY,
+ SELENIUM_SERVER_HOST_DEFAULT)
+
+def _selenium_server_port():
+ return int(os.environ.get(SELENIUM_SERVER_PORT_KEY,
+ SELENIUM_SERVER_PORT_DEFAULT))
+
+def _browser():
+ return os.environ.get(BROWSER_KEY, BROWSER_DEFAULT)
+
+def _app_host():
+ return os.environ.get(APP_HOST_KEY, APP_HOST_DEFAULT)
+
+def _app_port():
+ return int(os.environ.get(APP_PORT_KEY, '5698'))
+
+def _speed():
+ return os.environ.get(SPEED_KEY)
+
+
class Layer(object):
- # XXX make configurable:
# hostname and port of the Selenium RC server
- _server = 'localhost'
- _port = 4444
- _browser = '*firefox'
+ _server = _selenium_server_host()
+ _port = _selenium_server_port()
+ _browser = _browser()
- # override in subclass:
- # hostname and port of the app web server
- host = None
- port = None
+ # hostname and port of the local application.
+ host = _app_host()
+ port = _app_port()
__name__ = 'Layer'
@@ -41,6 +78,9 @@
self._server, self._port, self._browser,
'http://%s:%s/' % (self.host, self.port))
self.selenium.start()
+ speed = _speed()
+ if speed is not None:
+ self.selenium.set_speed(speed)
def tearDown(self):
self.selenium.stop()
More information about the checkins
mailing list