Questions tagged [playwright]

Playwright is a library to automate Chromium, WebKit and Firefox with a single API. Playwright is similar to Puppeteer, but with cross-browser support and Python, Java, and .NET bindings, in addition to Node.js.

Resources

2380 questions
10
votes
6 answers

Run grouped tests sequentially using Playwright

I'm using Playwright with nodejs and I have grouped a couple of tests together like this import { test, expect } from '@playwright/test'; test.describe('Add a simple invoice test', () => { test('01.Login & add an invoice', async ({ page }) =>…
Amrou
  • 371
  • 1
  • 3
  • 18
10
votes
2 answers

How to wait for JavaScript to finish in playwright

I am testing UI with Playwright and JavaScript. My code find an input element that can sometimes be a drop down, sometimes a text and sometimes a date. To handle this I enter value with 2 steps. First I fill the text and then click on tab key to…
Jacob
  • 1,135
  • 5
  • 14
  • 29
10
votes
4 answers

Playwright: Upload files from non-input element that cannot be used page.setInputFiles?

I'm working on uploading files through non-input HTML tag on Playwright. For example, you can use setInputFiles like this, and this works: await page.setInputFiles('input[type="file"]', './headphone.png') But apparently setInputFiles only works for…
ー PupSoZeyDe ー
  • 1,082
  • 3
  • 14
  • 33
10
votes
1 answer

How to run a custom js function in playwright

How can I run a custom js function in playwright? For example show an alert. I have already tried this way but it did not work. var url = await page.evaluate(async() => { await function alert() { alert("alert"); } await alert(); });
9
votes
1 answer

Playwright using JS ,getting - page.goto: net::ERR_ABORTED; maybe frame was detached? ===== logs ====== navigating to "URL", waiting until "load"

Trying to implement Playwright with java script to one of my new projects using POM framework but getting this error as below page.goto: net::ERR_ABORTED; maybe frame was detached? =========================== logs…
vinayanth . k
  • 91
  • 1
  • 2
9
votes
8 answers

playwright 'no tests found.' on simple copy of example.spec.ts

I have just installed playwright (v1.18.1) to try it out (Windows 11) and I feel like something is wrong. I can run the example.spec.ts script fine, but if I copy that file and then try to run the copy then I get a no tests found. error. The steps…
user1432181
  • 918
  • 1
  • 9
  • 24
9
votes
3 answers

Playwright how to wait for locator that matches multiple elements to not be visible

I am trying to wait for an element that indicates a page is still loading, and exists on the page multiple time, to not be visible (think table with loading data placeholders). Playwright documentation suggests using Locators is best practice, and…
bee-anchor
  • 119
  • 1
  • 1
  • 6
9
votes
4 answers

How to make CONDITIONAL STATEMENTS using SELECTORS on PLAYWRIGHT?

I need some help to make conditional statements using Playwright tests. I have a given selector, let's say a button, and I need to write a conditional statement like this: if (selector is not present/visible) do nothing and proceed with the…
9
votes
2 answers

Playwright - Test against different environments and different variables

Im looking to use Playwright to test against a web page. The system im working on has 4 different environments that we need to deploy against, for example the test urls may be www.test1.com www.test2.com www.test3.com www.test4.com The first…
OrdinaryKing
  • 411
  • 1
  • 7
  • 16
9
votes
3 answers

Using Playwright, page.url() is getting a previous url instead of the current url

I'm testing the navigation on our website using expect(page.url()).toContain('/nav');. When walking through the code I can clearly see that we hit that url string after the click. I've tried putting my code into and outside of a promise granting the…
CamdyCorn
  • 121
  • 1
  • 3
  • 9
9
votes
4 answers

How to download PDF files with Playwright? (Python)

I'm trying to automate the download of a PDF file using Playwright, I've the code working with Selenium, but some features in Playwright got my attention. The real problem the documentation isn't helpful. When I click on download I get this: And I…
K3yg
  • 93
  • 1
  • 5
9
votes
2 answers

How to select a dropdown option using playwright in JavaScript?

I would like to select "All" option from the below DOM using Playwright JS, and I have tried page.selectOption('select#rows per page', '-1'); and page.selectOption('id=mui-55656', '-1'); to no avail. Any help would be appreciated. Thanks.
gbackmania
  • 772
  • 3
  • 7
  • 17
9
votes
3 answers

How can you get the selected option of a dropdown with Playwright

I am using the C# Language Bindings of Playwright. Example HTML: