Skip to content

Commit

Permalink
Refactor driver initialization in undetected-chromedriver test_undete…
Browse files Browse the repository at this point in the history
…cted_chromedriver.py and examples
  • Loading branch information
theijhay committed Feb 15, 2025
1 parent f77377a commit f9a5cc2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion examples/web_ui/undetected_chromedriver/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ def __init__(self, driver):
super().__init__(driver)

def do(self):
self._driver.quit()
if self._driver:
self._driver.quit()
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ def setup_method(self, method):
from examples.web_ui.undetected_chromedriver import setup

self.app = Application()
self.app._driver = self.app.at(setup.OpenBrowserTransaction)._driver
self._app._driver = self._app.at(setup.OpenBrowserTransaction)._driver

def teardown_method(self, method):
"""Lazy import to avoid breaking the pipeline"""
from examples.web_ui.undetected_chromedriver import setup

self.app.at(setup.CloseBrowserTransaction)
self._app.at(setup.CloseBrowserTransaction, driver=self._app._driver)

@pytest.mark.parametrize("query", ["Guara framework", "undetected-chromedriver"])
def test_google_search(self, query):
from examples.web_ui.undetected_chromedriver import actions

self.app.at(actions.SearchGoogle, query=query).asserts(
self._app.at(actions.SearchGoogle, query=query).asserts(
it.Contains, "https://www.google.com/search"
)

0 comments on commit f9a5cc2

Please sign in to comment.