Skip to content

Instantly share code, notes, and snippets.

@Chandankkrr
Created July 22, 2021 12:11
Show Gist options
  • Save Chandankkrr/80e132d18916da61f0855d2fc3eebc3b to your computer and use it in GitHub Desktop.
Save Chandankkrr/80e132d18916da61f0855d2fc3eebc3b to your computer and use it in GitHub Desktop.
Capture page screenshot when expected container is not found during E2E test
var welcomeTextContainer = await page.QuerySelectorAsync($"text=Hello {email}");
if (welcomeTextContainer == null)
{
await page.ScreenshotAsync(
new PageScreenshotOptions
{
Path = "screenshot.png"
});
// fail test
throw new XunitException("Test failed, unable to find welcome text container");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment