Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: if SELENIUM_URI is set then Remote Webdriver should be used #201

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions pytest-webdriver/pytest_webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def webdriver(request):
""" Connects to a remote selenium webdriver and returns the browser handle.
Scoped on a per-function level so you get one browser window per test.
Creates screenshots automatically on test failures.

Attributes
----------
root_uri: URI to the pyramid_server fixture if it's detected in the test run
Expand All @@ -65,7 +65,13 @@ def webdriver(request):
except LookupError:
pass

if CONFIG.browser.lower() == 'phantomjs':
# Documentation says if SELENIUM_URI is set then Remote Webdriver should be used
if CONFIG.uri:
driver = webdriver.Remote(
CONFIG.uri,
browser_to_use(webdriver, CONFIG.browser)
)
elif CONFIG.browser.lower() == 'phantomjs':
driver = webdriver.PhantomJS(executable_path=CONFIG.phantomjs)
elif CONFIG.browser.lower() == 'chrome':
chrome_options = webdriver.ChromeOptions()
Expand All @@ -74,6 +80,7 @@ def webdriver(request):
chrome_options.add_argument('--disable-dev-shm-usage')
driver = webdriver.Chrome(chrome_options=chrome_options)
else:
# Fall back to Remote
selenium_uri = CONFIG.uri
if not selenium_uri:
selenium_uri = 'http://{0}:{1}'.format(CONFIG.host, CONFIG.port)
Expand Down