When using @playwright/test on GitHub Actions, you might face timeouts while taking screenshots. This can be due to different default timeout settings between Playwright and Puppeteer, and limited resources on virtual machines.
To resolve this issue, try the following steps:
timeout
option provided by Playwright to increase the timeout for specific actions in your test code.import { test } from '@playwright/test';
test('Screenshot example', async ({ page }) => {
await page.goto('https://ray.run/');
await page.screenshot({ path: 'screenshot.png', timeout: 60000 }); // Increase timeout to 60 seconds
});
Optimize your test code: Reduce the time each action takes by optimizing your test code. Check out Tips for Writing Efficient Playwright Test Scripts for some helpful tips.
Use faster virtual machines: Consider using more powerful virtual machines on GitHub Actions to improve performance.
Run tests in headless mode: If you're not already doing so, use headless mode when running tests on GitHub Actions, as it can improve performance.
import { test, expect } from '@playwright/test';
test.use({ headless: true });
test('Headless mode example', async ({ page }) => {
await page.goto('https://ray.run/');
// Your test code here
});
Keep in mind that timeouts can also be caused by network issues or other factors outside your control. In these cases, you might need to investigate further or seek help from the Playwright community.
If you still have questions, please ask a question and I will try to answer it.
Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].