bitbake: toaster: browser tests - add Selenium Docker container as driver

Adds the ability to specify a Selenium Docker container server as
a driver. This allows for repeatable tests independent of host.
Currently we assume you are using the Firefox container. Instructions
are located in the README in tests/browser.

(Bitbake rev: 7df842f8f8b2ae640109ed06729ab59c9469fc64)

Signed-off-by: brian avery <brian.avery@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
brian avery
2016-11-30 19:35:27 -08:00
committed by Richard Purdie
parent e74831eba7
commit da22be9904
2 changed files with 30 additions and 4 deletions

View File

@@ -39,7 +39,7 @@ from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.common.exceptions import NoSuchElementException, \
StaleElementReferenceException, TimeoutException
def create_selenium_driver(browser='chrome'):
def create_selenium_driver(cls,browser='chrome'):
# set default browser string based on env (if available)
env_browser = os.environ.get('TOASTER_TESTS_BROWSER')
if env_browser:
@@ -59,6 +59,15 @@ def create_selenium_driver(browser='chrome'):
return webdriver.Ie()
elif browser == 'phantomjs':
return webdriver.PhantomJS()
elif browser == 'remote':
# if we were to add yet another env variable like TOASTER_REMOTE_BROWSER
# we could let people pick firefox or chrome, left for later
remote_hub= os.environ.get('TOASTER_REMOTE_HUB')
driver = webdriver.Remote(remote_hub,
webdriver.DesiredCapabilities.FIREFOX.copy())
driver.get("http://%s:%s"%(cls.server_thread.host,cls.server_thread.port))
return driver
else:
msg = 'Selenium driver for browser %s is not available' % browser
raise RuntimeError(msg)
@@ -135,7 +144,7 @@ class SeleniumTestCaseBase(unittest.TestCase):
# instantiate the Selenium webdriver once for all the test methods
# in this test case
cls.driver = create_selenium_driver()
cls.driver = create_selenium_driver(cls)
cls.driver.maximize_window()
@classmethod