behave-framework/browserdriver/__init__.py
Greg Gauthier 4e3c267656
Some checks failed
Execute / build (3.12) (push) Failing after 24s
Pylint / build (3.12) (push) Successful in 10s
run the tests
2024-07-23 15:48:03 +01:00

43 lines
1.1 KiB
Python
Executable File

# pylint: disable=too-few-public-methods
from selenium import webdriver
class BrowserDriver:
@staticmethod
def get(browser=None, headless=True):
valid_browsers = ['chrome', 'firefox', 'safari', 'edge']
if browser in valid_browsers:
browser_method = globals()[browser]
return browser_method(headless)
raise ValueError(f"'{browser}' is not a supported browser")
def chrome(headless=True):
options = webdriver.ChromeOptions()
options.headless = headless
options.add_argument('--ignore-certificate-errors')
return webdriver.Chrome(options=options)
def firefox(headless=True):
options = webdriver.FirefoxOptions()
options.accept_insecure_certs = True
options.headless = headless
options.add_argument('--ignore-certificate-errors')
return webdriver.Firefox(options=options)
def edge(headless=True):
options = webdriver.EdgeOptions()
options.use_chromium = True
options.headless = headless
driver = webdriver.Edge(options=options)
return driver
def safari():
# Because safari driver is bundled with safari
return webdriver.Safari()