Skip to content
Snippets Groups Projects
Commit 8840d991 authored by Brandon Rodriguez's avatar Brandon Rodriguez
Browse files

Improve handling of selenium and firefox

parent 7703a362
Branches
Tags
No related merge requests found
...@@ -68,15 +68,18 @@ class LiveServerMixin(ResponseTestCaseMixin): ...@@ -68,15 +68,18 @@ class LiveServerMixin(ResponseTestCaseMixin):
# Add window position data to driver options. # Add window position data to driver options.
self._options.add_argument('window-position={0},{1}'.format(window_x, window_y)) self._options.add_argument('window-position={0},{1}'.format(window_x, window_y))
# Avoid possible error when many drivers are opened.
# See https://stackoverflow.com/a/56638103
global SELENIUM_DEBUG_PORT
SELENIUM_DEBUG_PORT += 1
# Create instance, based on selected driver type. # Create instance, based on selected driver type.
if self._browser == 'chrome': if self._browser == 'chrome':
# # Avoid possible error when many drivers are opened.
# # See https://stackoverflow.com/a/56638103
global SELENIUM_DEBUG_PORT
SELENIUM_DEBUG_PORT += 1
self._options.add_argument('--remote-debugging-port={0}'.format(SELENIUM_DEBUG_PORT)) self._options.add_argument('--remote-debugging-port={0}'.format(SELENIUM_DEBUG_PORT))
driver = webdriver.Chrome(service=self._service, options=self._options) driver = webdriver.Chrome(service=self._service, options=self._options)
elif self._browser == 'firefox': elif self._browser == 'firefox':
self._service = webdriver.firefox.service.Service(port=SELENIUM_DEBUG_PORT)
driver = webdriver.Firefox(service=self._service, options=self._options) driver = webdriver.Firefox(service=self._service, options=self._options)
else: else:
raise ValueError('Unknown browser "{0}".'.format(self._browser)) raise ValueError('Unknown browser "{0}".'.format(self._browser))
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment