Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions superset/utils/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,13 @@ def find_unexpected_errors(page: Page) -> list[str]:

return error_messages

@staticmethod
def _get_screenshot(page: Page, element: Locator, element_name: str) -> bytes:
Comment on lines +219 to +220
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect method pattern

The _get_screenshot method is incorrectly defined as a @staticmethod but is being called using the class name WebDriverPlaywright._get_screenshot() throughout the codebase. This breaks proper object-oriented design and prevents inheritance/mocking. The method should be an instance method (remove @staticmethod and use self) and all calls should use self._get_screenshot() instead of the class name prefix. This affects downstream calls in get_screenshot method at lines 373, 377, and 381.

Code suggestion
Check the AI-generated fix before applying
Suggested change
@staticmethod
def _get_screenshot(page: Page, element: Locator, element_name: str) -> bytes:
def _get_screenshot(self, page: Page, element: Locator, element_name: str) -> bytes:

Code Review Run #54df86


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them

if element_name == "standalone":
return page.screenshot(full_page=True)
else:
return element.screenshot()

def get_screenshot( # pylint: disable=too-many-locals, too-many-statements # noqa: C901
self, url: str, element_name: str, user: User
) -> bytes | None:
Expand Down Expand Up @@ -363,11 +370,18 @@ def get_screenshot( # pylint: disable=too-many-locals, too-many-statements # n
"falling back to standard screenshot"
)
)
img = element.screenshot()
img = WebDriverPlaywright._get_screenshot(
page, element, element_name
)
else:
img = element.screenshot()
img = WebDriverPlaywright._get_screenshot(
page, element, element_name
)
else:
img = element.screenshot()
img = WebDriverPlaywright._get_screenshot(
page, element, element_name
)
Comment on lines +373 to +383
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect method calls

The calls to _get_screenshot use the class name prefix WebDriverPlaywright._get_screenshot() instead of the instance method pattern self._get_screenshot(). This needs to be updated along with removing the @staticmethod decorator to maintain proper OOP design and enable inheritance/testing.

Code suggestion
Check the AI-generated fix before applying
Suggested change
img = WebDriverPlaywright._get_screenshot(
page, element, element_name
)
else:
img = element.screenshot()
img = WebDriverPlaywright._get_screenshot(
page, element, element_name
)
else:
img = element.screenshot()
img = WebDriverPlaywright._get_screenshot(
page, element, element_name
)
img = self._get_screenshot(
page, element, element_name
)
else:
img = self._get_screenshot(
page, element, element_name
)
else:
img = self._get_screenshot(
page, element, element_name
)

Code Review Run #54df86


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them


except PlaywrightTimeout:
# raise again for the finally block, but handled above
pass
Expand Down
Loading