Im using playwright to automate website testing but ran into the following Error:
The following code is how i reproduced the error, but i cant figure out why it resolves to an error.
Running test in vscode and --ui mode gives same error, using chromium and Playwright latest versions
import { test } from '@playwright/test';
test("crashes?", async ({ page }) =>{
page.goto('https://testpages.herokuapp.com/styled/basic-ajax-test.html');
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.getByRole('button', { name: 'Code In It' }).click();
await page.getByRole('link', { name: 'Go back to the form' }).click();
})
I expect the code to finish instead of returning an error
Solution to your issue is to "Increase default timeout"
test.setTimeout(1200000);
In your shared screenshot: Test timeout of 30000ms exceeded
Checkout this for more info: https://playwright.dev/docs/test-timeouts#test-timeout
Also: One of the issues with Playwright is it is very fast, it has a way of waiting for an element to be clicked but in your code after repeating the same steps the server becomes slow, and then the code is visible in UI but not clickable. This a classic problem that I have faced a lot.
A simple solution is to have
page.waitForLoadState('networkidle')
Here is the code which is working fine!!
import { test } from '@playwright/test';
test("crashes?", async ({ page }) =>{
test.setTimeout(1200000);
await page.goto('https://testpages.herokuapp.com/styled/basic-ajax-test.html');
for (let i=0; i<=150; i+=1) {
await page.getByRole('button', { name: 'Code In It' }).click();
await page.waitForTimeout(500);
await page.getByRole('link', { name: 'Go back to the form' }).click();
await page.waitForTimeout(500);
}
})