diff options
author | Tulio Casagrande <tcasagra@thoughtworks.com> | 2016-12-01 15:58:18 -0200 |
---|---|---|
committer | Tulio Casagrande <tcasagra@thoughtworks.com> | 2016-12-01 15:58:18 -0200 |
commit | a62d42cbf8c1fcf1785ddb21f374beb58231a2f5 (patch) | |
tree | 3413b10a2b3eef42939b502639a79eb4a145f016 /service/test/functional/features | |
parent | 76ad8f023dfabb25e93f771e44164b06004cd7a4 (diff) |
Add support to use different webdrivers
See: https://github.com/pixelated/project-issues/issues/381
Diffstat (limited to 'service/test/functional/features')
-rw-r--r-- | service/test/functional/features/environment.py | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/service/test/functional/features/environment.py b/service/test/functional/features/environment.py index b51323fa..a30f3221 100644 --- a/service/test/functional/features/environment.py +++ b/service/test/functional/features/environment.py @@ -30,6 +30,11 @@ from pixelated.resources.features_resource import FeaturesResource from test.support.integration import AppTestClient from steps.common import DEFAULT_IMPLICIT_WAIT_TIMEOUT_IN_S + +class UnsuportedWebDriverError(Exception): + pass + + setup() @@ -39,11 +44,7 @@ def start_app_test_client(client, mode): def before_all(context): - context.browser = webdriver.PhantomJS() - context.browser.set_window_size(1280, 1024) - context.browser.implicitly_wait(DEFAULT_IMPLICIT_WAIT_TIMEOUT_IN_S) - context.browser.set_page_load_timeout(60) - + _setup_webdriver(context) userdata = context.config.userdata context.host = userdata.get('host', 'http://localhost') @@ -61,6 +62,24 @@ def before_all(context): context.username = 'username' +def _setup_webdriver(context): + browser = context.config.userdata.get('webdriver', 'phantomjs') + supported_webdrivers = { + 'phantomjs': webdriver.PhantomJS, + 'firefox': webdriver.Firefox, + 'chrome': webdriver.Chrome, + } + + try: + context.browser = supported_webdrivers[browser]() + except KeyError: + raise UnsuportedWebDriverError('{} is not a supported webdriver'.format(browser)) + + context.browser.set_window_size(1280, 1024) + context.browser.implicitly_wait(DEFAULT_IMPLICIT_WAIT_TIMEOUT_IN_S) + context.browser.set_page_load_timeout(60) + + def _mock_user_agent(context): ensure_server() PixelatedSite.disable_csp_requests() |