Skip to content

Commit

Permalink
Fallback to Chrom(e|ium) if the Firefox driver for selenium isn't ava…
Browse files Browse the repository at this point in the history
…ilable
  • Loading branch information
Elena ``of Valhalla'' Grandi committed Jan 5, 2024
1 parent 36d882d commit cd9045f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/bepasty/tests/test_website.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from selenium.webdriver import Firefox
from selenium.webdriver.chrome.service import Service as ChromeService
from selenium.webdriver import Chrome
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import (
NoSuchDriverException, NoSuchElementException
)

import pytest

Expand All @@ -17,7 +21,11 @@ def setup_class(self):
"""
Setup: Open a mozilla browser, login
"""
self.browser = Firefox()
try:
self.browser = Firefox()
except NoSuchDriverException:
service = ChromeService(executable_path="/usr/bin/chromedriver")
self.browser = Chrome(service=service)
self.browser.get('http://localhost:5000/')
token = self.browser.find_element_by_name("token")
password = "foo"
Expand Down

0 comments on commit cd9045f

Please sign in to comment.