Rayrun

How do I resolve screenshot timeouts in Playwright on GitHub Actions when it works fine with Puppeteer locally?

Answer

Increase Timeout and Optimize Test Code

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:

  1. Increase the timeout for actions: Use the 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
});
  1. 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.

  2. Use faster virtual machines: Consider using more powerful virtual machines on GitHub Actions to improve performance.

  3. 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.

Thank you!
Was this helpful?
Still have questions?

If you still have questions, please ask a question and I will try to answer it.

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

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].