Skip to content

Commit

Permalink
Introduce cls_driver and cls_wd_options to WebDriver
Browse files Browse the repository at this point in the history
  • Loading branch information
jrycw committed Nov 18, 2024
1 parent 1b599da commit e0b6365
Showing 1 changed file with 12 additions and 21 deletions.
33 changes: 12 additions & 21 deletions great_tables/_utils_selenium.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@

class _BaseWebDriver:

def __init__(self):
def __init__(self, debug_port: bool):
self.debug_port = debug_port
self.wd_options = self.cls_wd_options()
self.add_arguments()
self.driver = self.cls_driver(self.wd_options)

def add_arguments(self): ...

Expand All @@ -34,11 +37,8 @@ def __exit__(


class _ChromeWebDriver(_BaseWebDriver):
def __init__(self, debug_port: int | None = None):
self.debug_port = debug_port
self.wd_options = webdriver.ChromeOptions()
super().__init__()
self.driver = webdriver.Chrome(self.wd_options)
cls_driver = webdriver.Chrome
cls_wd_options = webdriver.ChromeOptions

def add_arguments(self):
self.wd_options.add_argument("--headless=new")
Expand All @@ -47,19 +47,13 @@ def add_arguments(self):


class _SafariWebDriver(_BaseWebDriver):
def __init__(self, debug_port: int | None = None):
self.debug_port = debug_port
self.wd_options = webdriver.SafariOptions()
super().__init__()
self.driver = webdriver.Safari(self.wd_options)
cls_driver = webdriver.Chrome
cls_wd_options = webdriver.SafariOptions


class _FirefoxWebDriver(_BaseWebDriver):
def __init__(self, debug_port: int | None = None):
self.debug_port = debug_port
self.wd_options = webdriver.FirefoxOptions()
super().__init__()
self.driver = webdriver.Firefox(self.wd_options)
cls_driver = webdriver.Firefox
cls_wd_options = webdriver.FirefoxOptions

def add_arguments(self):
self.wd_options.add_argument("--headless")
Expand All @@ -68,11 +62,8 @@ def add_arguments(self):


class _EdgeWebDriver(_BaseWebDriver):
def __init__(self, debug_port: int | None = None):
self.debug_port = debug_port
self.wd_options = webdriver.EdgeOptions()
super().__init__()
self.driver = webdriver.Edge(self.wd_options)
cls_driver = webdriver.Edge
cls_wd_options = webdriver.EdgeOptions

def add_arguments(self):
self.wd_options.add_argument("--headless")

Check warning on line 69 in great_tables/_utils_selenium.py

View check run for this annotation

Codecov / codecov/patch

great_tables/_utils_selenium.py#L69

Added line #L69 was not covered by tests
Expand Down

0 comments on commit e0b6365

Please sign in to comment.