Skip to main content

Questions tagged [playwright-typescript]

The tag has no usage guidance.

playwright-typescript
Filter by
Sorted by
Tagged with
5 votes
4 answers
9k views

playwright page.getByLabel() resolved to 2 elements

I am learning playwright and i find page.getByLabel is very usefulm but i try to find input elements i think finds the same twice. > test('Fill Contact details and verify should success', async ({ ...
MiklosBalazsi's user avatar
3 votes
1 answer
6k views

How to get the current test name for Playwright in TypeScript?

Here is what I have implemented for NUnit when using Playwright. I would like to do the same thing for TypeScript with Playwright. public string GetTestClassMethod() { return $"{TestContext....
Greg Finzer's user avatar
  • 6,924
3 votes
2 answers
2k views

locator.waitFor: Target closed in Playwright error even though the "Wait" handled

Im trying to implement Playwright/TS Page Object Model framework for a web app. So in this case Im automating login successful scenario by asserting user can see the Dashboard text. But Im getting the ...
AVI's user avatar
  • 5,665
3 votes
2 answers
7k views

Playwright - How to test that a network request have finished after on click event

I am making BDD test with a Cucumber-Playwright suit. A page I am making a test for has buttons that will trigger a PUT API request and update the page (Note: The button will not link to new address, ...
Mayur Kumar's user avatar
3 votes
1 answer
113 views

How to store the text contents of an element to a variable and log to console?

import { test, expect } from '@playwright/test'; test('test', async ({ page }) => { await page.goto('https://www.exploretock.com/whisperingvine4thstreet/'); await expect(page.getByText('guests'...
kylewhirl's user avatar
3 votes
2 answers
993 views

Can not access text inside Shadow DOM using playwright

I am trying to use playwright to assert text like below which is inside open shadow root which has no tags associated to that specific text. These texts are inside table cells. <div> <table-...
Chamath Erandika Rathnayake's user avatar
3 votes
3 answers
3k views

How to wait for multiple responses in Playwright [typescript]

We have a method in Playwright to wait for a response. page.waitForResponse But, I need to wait for multiple responses using waitForResponse. How can we achieve this? I have tried looping the ...
Ray's user avatar
  • 93
3 votes
1 answer
256 views

Why does playwright think the ARIA role for a <th> tag is `cell`?

Playwright emphasizes using "user-facing attributes and explicit contracts such as page.getByRole()" to locate items on a page. I want to locate a th tag on my page. Chrome's DevTools has an ...
pcronin's user avatar
  • 1,099
3 votes
2 answers
2k views

Playwright. The run test button does not appear

I'm starting to learn the Playwright. It's my first try to run a test. I've installed the Playwright Test for VSCode extention, then I've run npm init playwright@latest --yes -- --quiet --browser=...
Olga Vinikovetsky's user avatar
3 votes
1 answer
1k views

Playwright Compare screenshot against existing image

take clip screenshort compare screenshort against existing picture stored in my repo const screenshot = await page.screenshot({ clip: { height: 20, width: 20, x: 630, y: 283 }, path: `${name}Icon.png`...
mbdev's user avatar
  • 43
2 votes
3 answers
609 views

Dynamically generate Playwright test asynchronously, shows No test found

The Playwright documentation has a parameterize sample like this. It works: const people = ['Alice', 'Bob']; for (const name of people) { test(`testing with ${name}`, async () => { // ... })...
QQ321's user avatar
  • 43
2 votes
2 answers
855 views

Playwright : How to continue test execution after assertion failed?

I need to run multiple links on a single test. The test scenarios are almost the same for the 4 links, but will have different color or data. I have tried this, but once link A has failed, it will ...
carlosng07's user avatar
2 votes
2 answers
46 views

How to find an element by using Or in the locator?

I have 2 very similar elements one different pages that I need to test: <input name="myName"> <input name="name"> In my code I tried to find the input element using Or ...
Tal Angel's user avatar
  • 1,602
2 votes
1 answer
198 views

Playwright: Unable to capture URL address of a new tab in headless mode

The test fails in headless mode, but when mode is headless: false test passed. await productAttachment.element.click(); // this action opens a new page with a pdf attachment const newPage = await ...
Michał Ziętek's user avatar
2 votes
1 answer
3k views

Playwright "setup" project not executing before dependent projects

I'm trying to add a setup project to Playwright like the Auth documentations recommends: Create a new setup project in the config and declare it as a dependency for all your testing projects. This ...
Chen Peleg's user avatar
  • 1,582
2 votes
2 answers
459 views

How to write waitForElementText method in Playwright

I would like to have waitForElementText() in playwright. E.g I have headers on each page cssSelector = '.header-name'. and I navigate from Home page to Users I pass two arguments to the method: ...
Vasyl's user avatar
  • 21
2 votes
0 answers
82 views

Playwright contexts over websocket not working

I'm spawning Playwright on my local machine in one codebase, then connecting to it over websocket in another codebase (also on my local machine). The server is being spawned fine, and as it's not in ...
jzw's user avatar
  • 23
2 votes
0 answers
769 views

Why am I getting the Playwright Test did not expect ${title} to be called here when I try to execute a test from the testRunner.ts file?

I have .spec.ts test files in the tests folder and i have the testRunner.ts file in the parent directory. I hav built the project using tsc and configured to store the generated js files in a dist ...
Akshitha Dalpethado's user avatar
2 votes
2 answers
2k views

Issue with Playwright running multiple workers and executing hooks multiple times

I'm experiencing an unexpected behavior with Playwright when running tests with multiple workers. According to the Playwright documentation, the beforeAll hook should be executed ONCE PER WORKER. ...
Bananasaurus's user avatar
2 votes
2 answers
990 views

Get specific cell value from Playwright typescript

I have a table with n columns and rows. Would like to fetch "Column X" value whose "Name" is "Ram" through playwright I have tried through Iteration but didnt work (All ...
sri chirukuri's user avatar
1 vote
2 answers
118 views

Is there any reason why toBeInViewport() shouldn't replace toBeVisible() in most circumstances?

I have been using .toBeVisible() to check if an element is displayed on the page. However in a few circumstances the element is visible to human eye and intractable. In these cases I've been using ...
Kieran M's user avatar
  • 437
1 vote
3 answers
4k views

How to: Interact with a slider using Playwright

What I expected I am attempting to interact with a slider ui element on my angular based webpage. The code shown below is not interacting with the elements in question anymore. It was at one point.. ...
JIOSH's user avatar
  • 53
1 vote
2 answers
366 views

How to check the alignment of a text using playwright typescript

I want to validate if the text in my page is left or right aligned. In selenium one can use driver.findElement(By.id("id1")).getLocation().x; to get the location of an element in the page ...
jba065's user avatar
  • 331
1 vote
2 answers
2k views

playwright what is the best practice to test localisation

I am learning playwright and it highly recommends to use customer facing selectors... so that rises a question what is the best approach for localisation testing. I am using https://practice....
MiklosBalazsi's user avatar
1 vote
1 answer
978 views

Getting Error: page.goto: Test ended. in playwright

I am trying to create a function like this in playwright. By the way, I am new to playwright. import { expect } from "@playwright/test"; import { EnvCredentials } from "../helpers/...
simpleMan's user avatar
1 vote
2 answers
566 views

How to share a variable's value between parametrized and non parametrized test in Playwright with Typescript?

As in the title. Here's where I came from: Sharing variable's value worked fine before I introduced parametrization. imports { ... } ... let myVariable: string; test.describe.configure({mode: ...
An2023's user avatar
  • 11
1 vote
1 answer
90 views

Why can't I use page.locator in a page.waitForFunction?

I'm experimenting a bit with Playwright, with my Cypress background I'm comfortable with the cypress-wait-until function. I try to wait until an expected number of a DOM elements exist. Meanwhile I ...
im-a-train's user avatar
1 vote
1 answer
217 views

How to convert the Playwright Request Object into string as it gives promise only?

I am facing an issue where every time i need to compare response body to some string i need to use response.body().toString() with await which just complicated the code unnecessary is there any other ...
Hindi Premee's user avatar
1 vote
1 answer
76 views

Playwright onEnd() results does not include duration like documentation specifies. What am I missing?

The build in method onEnd can has a results object that can be accessed within the onEnd function. Per the documentation here, it will include the property duration which is number in milliseconds. ...
karcaroth's user avatar
1 vote
1 answer
295 views

How to check if an element is visible?

I want to check if an element is visible. If so, I want to click on it. If not, I want to check if another html element is available and click on it. How can I do this using playwright? The html ...
Rue Vitale's user avatar
  • 1,793
1 vote
1 answer
58 views

How to perform Automation testing for two-three days business process [closed]

I'm relatively new to Automation testing. I've seen notes on automation testing for Static web pages and dynamic ones, even data driven. But in my project, we've got a web page where we load trades ...
Nishanth Balaji's user avatar
1 vote
1 answer
684 views

Is it possible to preserve login state during development in playwright ui mode?

I configured my project as described here: https://playwright.dev/docs/auth, to store state after login, and it works fine in subsequent tests. My question is whether it's possible to maintain state ...
Mateusz Marchel's user avatar
1 vote
1 answer
176 views

How to avoid Playwright reading the configuration file and creating separate instance for each workers?

Does Playwright reads the configuration file for each worker? For example, If I have set the number of workers to 3 in my Playwright configuration file, does it means that Playwright will create three ...
Sushmitha Venkatesh's user avatar
1 vote
1 answer
1k views

Setup for Playwright test suit for authentication

I have Playwright suite to test an Angular 15 app and I'm trying to set up an auth scheme so tests could use it to simulate an authenticated user. According to the basic setup docs, I've added a ...
Chen Peleg's user avatar
  • 1,582
1 vote
1 answer
5k views

How to get the current context in Playwright?

I have a need to open a URL in a new tab. How do I get the current context of Playwright in TypeScript? Here is what I have for C#: public async Task<int> OpenUrlInNewTab(string url) { var ...
Greg Finzer's user avatar
  • 6,924
1 vote
0 answers
50 views

Playwright - route.fetch: Test ended error [closed]

In my SPA, I am using page.route() to intercept an api request. Ex: /core The same api is getting called multiple times when I move across the pages and finally, test fails with a message route.fetch: ...
bageesh lal's user avatar
1 vote
0 answers
30 views

Is there a way that playwright can run the teardown of a playwright project even if test gets interrupted by using cmd + c

projects: [ { name: 'citizen-users-teardown', testMatch: '**playwright/tests/bootstrap/users/citizen-users.teardown.ts', }, { name: 'citizen-users-setup', testMatch:...
kda_100's user avatar
  • 157
1 vote
1 answer
87 views

Playwright form field filling is inconsistent

I have a problem with testing this site. When I enter data, it can happen that, for example, from firefox, webkit, chrome, for one they do not enter, they leave empty fields, or there is a timeout or ...
Hzastack's user avatar
1 vote
0 answers
83 views

How to run tests in parallel in playwright having access to the test parameters

Playwright has documentation about how to parametrize tests from using project/fixture options: import { test as base } from '@playwright/test'; export type TestOptions = { person: string; }; ...
Danielo515's user avatar
  • 6,811
1 vote
2 answers
130 views

Handle values in input field in Playwright

Lets imagine that we have a pretty simple task for PLaywright. In opened form we should refill values in the input fields. In input field 1 we should set a new value "John". In field 2 we ...
Alia Bey's user avatar
1 vote
1 answer
61 views

How to indicate which project initiate the setup (project) process in Playwright

In my playwright.config file I have multiple projects that all has the same setup project as a dependency project. Is there any way to indicate on runtime, which parent project initiate the setup ...
I.sh.'s user avatar
  • 1,299
1 vote
0 answers
227 views

process.env variables set inside setup project of playwright not available inside test projects

I am using Playwright with Typescript. I am trying to set sessionStorage and authToken env variables in playwright in a setup step and trying to reuse them in a test project as shown here: https://...
Pramod Yadav's user avatar
1 vote
0 answers
148 views

After hooks in playwright takes time to finish

Playwright version: 1.43.1 I am currently investigating why some of my e2e tests are very slow; if it needs to be rewritten or just need to increase the default timeout. I recognize some tests that ...
Leicester Digitalis's user avatar
1 vote
1 answer
74 views

Playwright button click inside iFrame just Waiting

I'm newer to Playwright and I can't figure out why this isn't working. I'm working within a framework that is providing iFrames without an id or class. I am trying to click on one of the buttons in ...
Richard Eddy's user avatar
1 vote
0 answers
92 views

Is there a way to add custom matchers in Playwright using generics?

Since version 1.39 of Playwright we now have a way to create custom matchers with Typescript support that makes the old way of doing it obsolete. With the new way we can do something like: export ...
David Guevara's user avatar
1 vote
0 answers
72 views

In Playwright, how to define globally functions to be automatically executed in testHooks?

I am new to Playwright and I am struggling with hooks. For my project, I need all tests and executions, to perform some actions on : beforeAll(), beforeEach(), afterEach() and afterAll() hooks. Is ...
Artherone's user avatar
1 vote
1 answer
77 views

Why doesn't filter() work narrowing the Locator

I can't publish the code, but I wrote this HTML file that replicates the scenario (https://coral-nanci-88.tiiny.site/): <!DOCTYPE html> <html lang="en"> <head> ...
Vitto's user avatar
  • 401
1 vote
1 answer
326 views

Unable to resolve signature of method decorator when called as an expression

I am working on a TypeScript project where I am trying to use decorators to add steps to Playwright tests. My goal is to create a custom decorator that wraps methods with Playwright's test.step ...
Alina's user avatar
  • 11
1 vote
1 answer
172 views

Is there a way to store dynamically generated username in playwright for later use?

Let's say I have three files - adminDetails.ts 001-onboardUser.spec.ts 002-login.spec.ts I'm generating username dynamically in my 001-onboardUser.spec.ts file- import {adminDetails} from './...
Pranav 's user avatar
1 vote
1 answer
906 views

Playwright: cant set Host header for APIRequestContext

I'm currently trying to automate sending API calls to Gmail API. Sending requests with Postman works fine. Using Fetch library works fine. Sending the same request using APIRequestContext in ...
kazeeno's user avatar