Skip to content

Instantly share code, notes, and snippets.

@MonteLogic
Created June 7, 2024 16:44
Show Gist options
  • Save MonteLogic/497dd5a9c12d2e0f80775225b8d3508e to your computer and use it in GitHub Desktop.
Save MonteLogic/497dd5a9c12d2e0f80775225b8d3508e to your computer and use it in GitHub Desktop.
import { test, expect } from '@playwright/test';
test('checks render for DistributorHeader filter', async ({ page }) => {
console.log('Before page.goto');
await page.goto('/', { timeout: 60000 });
console.log('After page.goto');
await page.waitForLoadState('networkidle');
const headingLocator = page.locator('h1.text-xl.font-bold');
const headingVisible = await headingLocator.isVisible();
console.log('Heading visible:', headingVisible);
const listItemLocator = page.locator('ul li h4');
const listItemVisible = await listItemLocator.isVisible();
console.log('List item visible:', listItemVisible);
const imageLocator = page.locator('ul li a img');
const imageVisible = await imageLocator.isVisible();
console.log('Image visible:', imageVisible);
const linkLocator = page.locator('a.inline-flex');
const linkVisible = await linkLocator.isVisible();
console.log('Link visible:', linkVisible);
// Log any console messages from the page
page.on('console', msg => console.log(msg.text()));
// Evaluate JavaScript within the page context
const pageContent = await page.evaluate(() => {
// Check for the presence of specific elements or log any error messages
const element = document.querySelector('selector-for-element');
if (element) {
console.log('Element found');
} else {
console.log('Element not found');
}
return document.body.innerText;
});
console.log('Page content:', pageContent);
// Produce a screenshot of the page
await page.screenshot({ path: 'screenshot.png' });
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment