playwright-test is the official test runner of playwright and is especially made for end-to-end testing.
Questions tagged [playwright-test]
329 questions
2
votes
2 answers
How do I intercept all f the page traffic in a scrollable website on playwright?
So I am using the following code:
import { firefox } from 'playwright';
// domain
let domain = 'https://www.reddit.com/'
// create a new page
const page = await browser.newPage();
// set routes
await page.route('**', async route => {
const…

Andjelko Topic
- 21
- 2
2
votes
2 answers
Playwright test afterEach but with a variable for certain tests
Each test uses await expect(page).toHaveScreenshot();. I wouldn't want to do repetitions in every test.
test.afterEach(async ({ page }) => {
await expect(page).toHaveScreenshot({mask: [] as Locator[] || null});
});
There is a problem. Some tests…

Chrystian C
- 23
- 3
2
votes
0 answers
How to adjust Playwright Codegen's locating priority/strategy in an Angular project with third-party component libraries?
This Angular project uses Emulated ViewEncapsulation, adds dynamically generated attributes like _ngcontent-xxx-c001 into most elements, which absolutely can't be used in E2E Test. Fortunately, Codegen does not seem to pick these attributes as…

igdswzcd109
- 21
- 1
2
votes
1 answer
Process.env not accessible while writing playwright-ct component testing?
I am using playwright for component testing, I have a following dir. structure in my next.js project.
./playwright
- component
./ MyComponent.spec.tsx
./ MyComponent.tsx
./ index.html
- fixtures
- index.ts
Unfortunately…

Divyanshu Rawat
- 4,421
- 2
- 37
- 53
2
votes
1 answer
How to get the exit code from playwright?
I'm running some playwright tests in a pipeline but I'm having problems trying to fail the build when a test fails.
In my pipeline I call a make file that calls a shell script that installs playwright, does some setup, and then runs the command yarn…

Doctor Who
- 1,287
- 5
- 25
- 46
2
votes
2 answers
Playwright JavaScript - How can I reuse locator variables within different tests?
I want to be able to use a locator variable within all the tests without having to define it every time inside each test.
Something like:
// @ts-check
const { test, expect } = require('@playwright/test');
test.beforeEach( async ({ page }) => {
…

Gus
- 39
- 2
2
votes
0 answers
how to add performance checks for Web Vitals scores in E2E testing with different network conditions using playwright
I want to check the web performances scores like First Contentful Paint (FCP), Time to Interactive (TTI), and other web vitals score using playwright and also want to check network throttling in different conditions like slow 3g how can that be…

ali
- 492
- 2
- 7
- 18
2
votes
1 answer
Property 'x' does not exist on type 'MakeMatchers'
I'm a newcomer to Typescript and am struggling to see why I get this error:
At the top of the file I import expect from Playwright:
import {expect} from "@playwright/test";
This function as shown comes from interface PageAssertions{ // within the…

Steerpike
- 1,712
- 6
- 38
- 71
2
votes
0 answers
Record a Test Starting From Another Test Not working with Playwright VS Code Extension
So I followed the exact documentation - But I am not able include test code from one file to another one using this feature.
I selected one specific line in the test and then clicked Record from here. But strangely new record is created butcode up…

Akshay J
- 31
- 3
2
votes
1 answer
Typescript readonly and getter method
I am using Typescript with Playwright and I am not certain what would be a best practice for Page object models.
For example:
export class OrderConfirmationPage extends GenericPage {
readonly orderConfirmationMessage: Locator;
constructor(page:…

mismas
- 1,236
- 5
- 27
- 55
2
votes
0 answers
playwright can't import from absolute path
I am writing playwright tests for a meteor react + nodejs app. My test resides in /tests/e2e I have to import some helpers in tests to prepare data, those helpers are using absolute imports
eg
import {CommentsModal} from…

Lutif Mandhro
- 21
- 2
2
votes
1 answer
How to Send Get request with Body using Playwright
I'm trying to send a get request with a body using playwright.
I did not find any resource / way how to do it.
I would like to query the elasticsearch using get request with payload.
example:
test("Get simki", async ({request})=> {
const…

Awesome Developer
- 43
- 2
- 5
2
votes
0 answers
Playwright expect timeout doesn’t work properly if you define a timeout on the playwright configuration file
I defined timeout 30 * 1000 for expect in playwright.config.ts file:
import type { PlaywrightTestConfig } from '@playwright/test';
import { devices } from '@playwright/test';
import * as os from 'os';
const config: PlaywrightTestConfig = {
…

Alon
- 35
- 1
- 5
2
votes
1 answer
Playwright tests work locally but fail when run in "npx playwright test" in Azure DevOps Pipelines with "error page.goto: net::ERR_CONNECTION_RESET"
Context:
Playwright Version: Version 1.25.0
Operating System: windows-latest
Node.js version: v16.13.1
Browser: Firefox and Chrome
Extra: Run via Azure DevOps Pipelines in the cloud. The application login starts with the app domain, then goes to…

ttqa
- 326
- 2
- 12
2
votes
0 answers
Playwright - How to access test results before running globalTeardown
In Playwright, after all tests have been executed, I am running a globalTeardown file that would send all of the test results to an external test management tool by making a series of api calls.
My intention was to access the jUnit.xml file and get…

kokodee
- 285
- 1
- 3
- 15