From 009660e10664320943808968d34b69f00c4daee1 Mon Sep 17 00:00:00 2001 From: Mike Shriver Date: Tue, 25 Oct 2022 19:50:14 -0400 Subject: [PATCH] Add element highlighting by default to the tests makes it easier to observe tests when making contributions --- testing/conftest.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/testing/conftest.py b/testing/conftest.py index 026102e2..e65ee9a6 100644 --- a/testing/conftest.py +++ b/testing/conftest.py @@ -6,6 +6,20 @@ from selenium import webdriver from wait_for import wait_for from widgetastic.browser import Browser +from widgetastic.browser import BrowserParentWrapper + + +class HighlightBrowser(Browser): + """Provide element highlighting during test execution""" + + def move_to_element(self, locator, *args, **kwargs): + kwargs["highlight_element"] = True + if isinstance(self, BrowserParentWrapper): + parent = self._o + el = self._browser.element(locator, parent=parent) + return self._browser.move_to_element(el, *args, **kwargs) + else: + return super().move_to_element(locator, *args, **kwargs) OPTIONS = {"firefox": webdriver.FirefoxOptions(), "chrome": webdriver.ChromeOptions()} @@ -73,5 +87,5 @@ def selenium(browser_name, wait_for_selenium, selenium_url): @pytest.fixture(scope="module") def browser(selenium, request): selenium.get(request.module.TESTING_PAGE_URL) - yield Browser(selenium) + yield HighlightBrowser(selenium) selenium.refresh()