You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "dosubot[bot] (via GitHub)" <gi...@apache.org> on 2026/05/02 03:09:23 UTC
Re: [D] How can I integrate Superset charts with PlayWright to ensure that all charts and data on the page are fully rendered and there are no unexpected errors before taking a screenshot? [superset]
GitHub user dosubot[bot] edited a comment on the discussion: How can I integrate Superset charts with PlayWright to ensure that all charts and data on the page are fully rendered and there are no unexpected errors before taking a screenshot?
<!-- Answer -->
To ensure all Superset charts and data are fully rendered and error-free before taking a screenshot with Playwright in C#, follow the same logic used by Superset's built-in Playwright automation:
1. Navigate to your Superset dashboard or chart URL.
2. Wait for the main container (e.g., `.dashboard` or the relevant class) to appear.
3. Wait for all `.chart-container` elements to be visible.
4. Wait for all `.loading` elements to disappear (state "detached"), which means charts have finished rendering.
5. (Optional) Wait a few seconds for chart animations to complete.
6. Check for error elements with `role="alert"` and extract error messages from `.antd5-modal-content .antd5-modal-body` if present.
7. Take the screenshot.
Here’s a C# Playwright code snippet that implements this logic:
```csharp
using Microsoft.Playwright;
using var playwright = await Playwright.CreateAsync();
await using var browser = await playwright.Chromium.LaunchAsync(new BrowserTypeLaunchOptions { Headless = true });
var page = await browser.NewPageAsync();
await page.GotoAsync("https://your-superset-url/superset/dashboard/123/", new PageGotoOptions { WaitUntil = WaitUntilState.Load });
// Wait for main dashboard container
await page.WaitForSelectorAsync(".dashboard");
// Wait for all chart containers to be visible
var chartContainers = await page.QuerySelectorAllAsync(".chart-container");
foreach (var chart in chartContainers)
{
await chart.WaitForElementStateAsync(ElementState.Visible);
}
// Wait for all loading spinners to disappear
var loadingElements = await page.QuerySelectorAllAsync(".loading");
foreach (var loading in loadingElements)
{
await loading.WaitForElementStateAsync(ElementState.Detached);
}
// Optional: wait for chart animations to finish
await page.WaitForTimeoutAsync(5000);
// Check for unexpected errors
var alerts = await page.QuerySelectorAllAsync("[role='alert']");
foreach (var alert in alerts)
{
var seeMoreBtn = await alert.QuerySelectorAsync("[role='button']");
if (seeMoreBtn != null)
{
await seeMoreBtn.ClickAsync();
var modalBody = await page.QuerySelectorAsync(".antd5-modal-content .antd5-modal-body");
if (modalBody != null)
{
var errorMsg = await modalBody.InnerTextAsync();
// Handle or log errorMsg as needed
}
var closeBtn = await page.QuerySelectorAsync(".antd5-modal-content .antd5-modal-close");
if (closeBtn != null)
await closeBtn.ClickAsync();
await page.WaitForSelectorAsync(".antd5-modal-content", new PageWaitForSelectorOptions { State = WaitForSelectorState.Detached });
}
}
// Take the screenshot
await page.ScreenshotAsync(new PageScreenshotOptions { Path = "dashboard.png" });
```
For large dashboards, consider a tiled screenshot approach: scroll the dashboard in view-sized increments, wait for content to settle after each scroll, and stitch the images together. This is how Superset handles dashboards that extend beyond the viewport [[source]](https://github.com/apache/superset/pull/34561).
You can tune timeouts and delays using Superset config options like `SCREENSHOT_PLAYWRIGHT_DEFAULT_TIMEOUT`, `SCREENSHOT_SELENIUM_ANIMATION_WAIT`, and `SCREENSHOT_SELENIUM_HEADSTART` [[source]](https://github.com/apache/superset/blob/master/superset/config.py).
There are no C#-specific examples in the Superset codebase, but the DOM structure and selectors are the same as in Python, so this approach is portable [[source]](https://github.com/apache/superset/discussions/36839).
<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=reply-with-mention&utm_term=apache%2Fsuperset).*
---
Share context across your team and agents. Try [Dosu](https://dosu.dev?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-tagline&utm_term=apache%2Fsuperset).
[](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-feedback&utm_term=apache%2Fsuperset&message_id=eec8805a-0752-4c3a-b1d8-e8ef30ae6c9a) [](https://github.dosu.com/apache/superset?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-learn-repo&utm_term=apache%2Fsuperset) [](https://app.dosu.dev/signup?referrer=openSource&source=github-footer&utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-add-team&utm_term=apache%2Fsuperset)
GitHub link: https://github.com/apache/superset/discussions/36845#discussioncomment-15349414
----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org