Issue 1:
System info

Playwright Version: [v1.35.1]

Operating System: [Ubuntu 20]

Browser: [WebKit]

Other info:

Source code

I provided exact source code that allows reproducing the issue locally.

I have not provided a sample repro for this as it's not something I can reproduce easily. It would probably be harder for me to try to create a smaller version of the code where I'm having this problem and then still be able to replicate it.

The app I'm working on is small and although I'm not comfortable exposing it as a public repo I would be open to creating a private repo and give access to the required people that would investigate this.

Alternatively, I'm open to getting on a discord call and demo the problem and provide any further information.

Problem description

When I run the tests I get a similar problem to what is reported in #20203. See the images below where the spacing between m and i in the word academic is not deterministic will sometimes make tests fail.

Diff:

Actual:

Expected:

I've tried the workaround proposed in #20203 but it didn't work for my case.

So far, the only workaround I found that seems reliably work is to do await page.waitForTimeout(1500); before I do await expect(page).toHaveScreenshot();. On my PC, I've tried 500ms and 1s and those always fail but the 1.5s seems to always be successful so far.

Any suggestions?

Notes

Initially this test would sometimes pass and sometimes fail. The way I got it to always fail when running locally was to run with workers: 1 instead of workers: undefined.

When running locally, I'm on a Windows 10 OS and I run the test via the docker image mcr.microsoft.com/playwright:v1.35.1-jammy.

When running this test on the CI server, the CI server uses an Ubuntu distro and it almost never fails. In the times where it fails, the fact that I have retries set to 2 in the playwright config when it's running on CI was enough to avoid a flaky pipeline.

Issue 2:
System info

Playwright Version: 1.32.3-beta-1681174265000

Operating System: Windows 11

Browser: [All, Chromium, Firefox, WebKit]

Other info:

Config file

// playwright.config.ts
import { defineConfig, devices } from '@playwright/test';

export default defineConfig({
{
name: 'android.chrome',
use: {
...devices['Pixel 5'],
},
},

{
name: 'ipad.safari',
use: {
...devices['iPad (gen 6)'],
},
}
});
```mdc.login.page.ts
import { expect, Locator, Page } from '@playwright/test';

const baseURL = String(process.env.URL);
const username = String(process.env.userid);
console.log(username);
const password = String(process.env.password);
const Title = String(process.env.Title);

export class mdcloginPage {

readonly page: Page;
readonly username_field : Locator;
readonly password_field : Locator;
readonly login_button : Locator;

// Locators

constructor(page: Page) {
this.page = page;
this.username_field = page.locator('input[name="username"]');
this.password_field = page.locator('input[name="password"]');
this.login_button = page.getByRole('button', { name: 'Login' });
}

//Actions
public async logintomdc() {
await this.page.goto(baseURL);

await expect((this.page),'checking page title').toHaveTitle(Title);
await this.page.screenshot({path: 'screenshot/title.png'});
/*await this.username_field.waitFor({state: "visible"});*/
await this.username_field.type(username);
await this.password_field.fill(password);
await this.login_button.click();

}
**Test file (self-contained)**

```MDC.spec.ts
import { test, expect } from "@playwright/test";
import {mdcloginPage} from "./mdc/mdc.login.page";

test.describe('MDC Regression', async() => {

test('mdc tc1', async ({ page }) => {
const mdclogin = new mdcloginPage(page);
mdclogin.logintomdc();
});
})

Steps

Expected

Navigate to url and fill username, password

click on login button.

Actual

it's closing the browser before it's loaded properly with below error

before hooks

page goto(url)

after hooks

Test finished within timeout of 30000ms, but tearing down "context" ran out of time.

Please allow more time for the test, since teardown is attributed towards the test timeout budget.

But when not following pom and I write the script in main test it's working fine

MDC.spec.ts

import { test, expect } from "@playwright/test";

import {mdcloginPage} from "./mdc/mdc.login.page";

test.describe('MDC Regression', async() => {

test('mdc tc1', async ({ page }) => {

const baseURL = String(process.env.URL);

const username1 = String(process.env.userid);

const password = String(process.env.password);

const Title = String(process.env.Title);

await page.goto(baseURL) ;

// Expect a title "to contain" a substring.
await expect((page),'checking page title').toHaveTitle(Title);
await page.screenshot({path: 'screenshot/title.png'})

await page.locator('input[name="username"]').fill(username1);
await page.locator('input[name="username"]').press('Tab');
await page.locator('input[name="password"]').fill(password);
await page.getByRole('button', { name: 'Login' }).click();

});

})

Above case it's working as expected

before Hooks

login to page

after Hooks