diff options
author | brian avery <avery.brian@gmail.com> | 2016-11-30 19:35:27 -0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-12-07 10:42:22 +0000 |
commit | da22be9904da257a168d72c2b00a6b839b0ed434 (patch) | |
tree | 0e6a0b8b1d8159e0a9720e575652e0ebcc14768b /bitbake/lib/toaster/tests/browser/selenium_helpers_base.py | |
parent | e74831eba7ddd910de33fbdb8f9fa1bd93fe893c (diff) | |
download | poky-da22be9904da257a168d72c2b00a6b839b0ed434.tar.gz |
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>
Diffstat (limited to 'bitbake/lib/toaster/tests/browser/selenium_helpers_base.py')
-rw-r--r-- | bitbake/lib/toaster/tests/browser/selenium_helpers_base.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/bitbake/lib/toaster/tests/browser/selenium_helpers_base.py b/bitbake/lib/toaster/tests/browser/selenium_helpers_base.py index 14e9c15648..156d639b1e 100644 --- a/bitbake/lib/toaster/tests/browser/selenium_helpers_base.py +++ b/bitbake/lib/toaster/tests/browser/selenium_helpers_base.py | |||
@@ -39,7 +39,7 @@ from selenium.webdriver.common.desired_capabilities import DesiredCapabilities | |||
39 | from selenium.common.exceptions import NoSuchElementException, \ | 39 | from selenium.common.exceptions import NoSuchElementException, \ |
40 | StaleElementReferenceException, TimeoutException | 40 | StaleElementReferenceException, TimeoutException |
41 | 41 | ||
42 | def create_selenium_driver(browser='chrome'): | 42 | def create_selenium_driver(cls,browser='chrome'): |
43 | # set default browser string based on env (if available) | 43 | # set default browser string based on env (if available) |
44 | env_browser = os.environ.get('TOASTER_TESTS_BROWSER') | 44 | env_browser = os.environ.get('TOASTER_TESTS_BROWSER') |
45 | if env_browser: | 45 | if env_browser: |
@@ -59,6 +59,15 @@ def create_selenium_driver(browser='chrome'): | |||
59 | return webdriver.Ie() | 59 | return webdriver.Ie() |
60 | elif browser == 'phantomjs': | 60 | elif browser == 'phantomjs': |
61 | return webdriver.PhantomJS() | 61 | return webdriver.PhantomJS() |
62 | elif browser == 'remote': | ||
63 | # if we were to add yet another env variable like TOASTER_REMOTE_BROWSER | ||
64 | # we could let people pick firefox or chrome, left for later | ||
65 | remote_hub= os.environ.get('TOASTER_REMOTE_HUB') | ||
66 | driver = webdriver.Remote(remote_hub, | ||
67 | webdriver.DesiredCapabilities.FIREFOX.copy()) | ||
68 | |||
69 | driver.get("http://%s:%s"%(cls.server_thread.host,cls.server_thread.port)) | ||
70 | return driver | ||
62 | else: | 71 | else: |
63 | msg = 'Selenium driver for browser %s is not available' % browser | 72 | msg = 'Selenium driver for browser %s is not available' % browser |
64 | raise RuntimeError(msg) | 73 | raise RuntimeError(msg) |
@@ -135,7 +144,7 @@ class SeleniumTestCaseBase(unittest.TestCase): | |||
135 | 144 | ||
136 | # instantiate the Selenium webdriver once for all the test methods | 145 | # instantiate the Selenium webdriver once for all the test methods |
137 | # in this test case | 146 | # in this test case |
138 | cls.driver = create_selenium_driver() | 147 | cls.driver = create_selenium_driver(cls) |
139 | cls.driver.maximize_window() | 148 | cls.driver.maximize_window() |
140 | 149 | ||
141 | @classmethod | 150 | @classmethod |