kgabryje commented on code in PR #26224:
URL: https://github.com/apache/superset/pull/26224#discussion_r1420507245
##########
superset/utils/webdriver.py:
##########
@@ -166,34 +152,40 @@ def get_screenshot(self, url: str, element_name: str,
user: User) -> bytes | Non
)
self.auth(user, context)
page = context.new_page()
- page.goto(
- url,
wait_until=current_app.config["SCREENSHOT_PLAYWRIGHT_WAIT_EVENT"]
- )
+ try:
+ page.goto(
+ url,
+
wait_until=current_app.config["SCREENSHOT_PLAYWRIGHT_WAIT_EVENT"],
+ )
+ except PlaywrightTimeout:
+ logger.exception(
+ "Web event %s not detected. Page %s might not have been
fully loaded",
+ current_app.config["SCREENSHOT_PLAYWRIGHT_WAIT_EVENT"],
+ url,
+ )
+
img: bytes | None = None
selenium_headstart =
current_app.config["SCREENSHOT_SELENIUM_HEADSTART"]
logger.debug("Sleeping for %i seconds", selenium_headstart)
page.wait_for_timeout(selenium_headstart * 1000)
- element: ElementHandle
+ element: Locator
try:
try:
# page didn't load
logger.debug(
"Wait for the presence of %s at url: %s",
element_name, url
)
- element = page.wait_for_selector(
- f".{element_name}",
- timeout=self._screenshot_locate_wait * 1000,
- )
+ element = page.locator(f".{element_name}")
+ element.wait_for()
except PlaywrightTimeout as ex:
logger.exception("Timed out requesting url %s", url)
raise ex
try:
# chart containers didn't render
logger.debug("Wait for chart containers to draw at url:
%s", url)
- page.wait_for_selector(
- ".slice_container",
timeout=self._screenshot_locate_wait * 1000
- )
+ for slice_container_elem in
page.locator(".slice_container").all():
Review Comment:
Yes, `page.locator` returns a `Locator` object, not `None` or list of html
elements
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]