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
39
votes
10 answers

How to check if an element exists on the page in Playwright.js

I am using playwright.js to write a script for https://target.com, and on the page where you submit shipping information, it will provide the option to use a saved address if you have gone through the checkout process previously on that target…
cole
  • 393
  • 1
  • 3
  • 4
32
votes
2 answers

What is the difference between testing on Safari vs Webkit?

I'm looking at writing some E2E tests using Playwright. I can see that the library allows tests to be run against Chromium, Firefox and Webkit. My understanding is that Webkit is the underlying engine of Safari, and Chromium is the base of Chrome…
user1087943
  • 489
  • 1
  • 7
  • 15
31
votes
5 answers

Getting value of input element in Playwright

How do I return the value of elem so that I can verify that it is in fact 1? const elem = await page.$('input#my-input') await elem.fill('1')
JakeDK
  • 966
  • 1
  • 9
  • 18
28
votes
6 answers

How can I assert that an element is NOT on the page in playwright?

I'm testing a website that includes a logo, and I want to make sure the logo does not appear on some pages. How can I assert that an element does NOT exist? I checked the Playwright assertions documentation, but it only has examples of checking for…
Patrick Kenny
  • 4,515
  • 7
  • 47
  • 76
25
votes
2 answers

Get current page url with Playwright Automation tool?

How can I retrieve the current URL of the page in Playwright? Something similar to browser.getCurrentUrl() in Protractor?
gabogabans
  • 3,035
  • 5
  • 33
  • 81
24
votes
4 answers

Playwright error (Target closed) after navigation

I'm trying something really simple: Navigate to google.com Fill the search box with "cheese" Press enter on the search box Print the text for the title of the first result So simple, but I can't get it to work. This is the code: const playwright =…
22
votes
4 answers

How can I increase the test time out value in jest?

I want to verify a function that can get update after one minute, and I set some sleep in my code, but my default time out value is 15000 ms, my code has sleep 60000ms so it returns this error: thrown: "Exceeded timeout of 15000 ms for a test. …
Ryan
  • 850
  • 1
  • 5
  • 16
20
votes
7 answers

How to get a collection of elements with playwright?

How to get all images on the page with playwright? I'm able to get only one (ElementHandle) with following code, but not a collection. const { chromium } = require("playwright"); class Parser { async parse(url) { const browser = await…
CoderDesu
  • 697
  • 1
  • 5
  • 14
15
votes
14 answers

Playwright VSCode gives `No tests found` message

I've installed the Playwright vscode extension but when I go to the testing area I get a "No tests have been found in this workspace" message. But when I run $> playwright test on the CLI it works like a charm. The weird thing is, that some time ago…
Jeanluca Scaljeri
  • 26,343
  • 56
  • 205
  • 333
15
votes
2 answers

How to get an element's attribute in a Playwright test?

I'm trying to get an element's attribute in a test. My test looks like this: test(`Should be at least 5 characters long`, async({ page }) => { await page.goto('http://localhost:8080'); const field = await page.locator('id=emailAddress'); …
Dev
  • 921
  • 4
  • 14
  • 31
15
votes
4 answers

How to read a textbox value from a playwright

I have input text field on the page with id "email30" and I am trying to read it's value from Playwright let dd_handle = await page.$("#email30"); let value = await dd_handle.getAttribute("value"); However it come back "" although I have a…
Paresh Varde
  • 1,084
  • 3
  • 16
  • 39
14
votes
1 answer

How to achieve browser resizing in run time using playwright? in a e2e test run

We have in protractor like: browser.driver.manage().window().setSize( width - 30, height ); How to achieve this in playwright?
14
votes
2 answers

In Playwright, how to pass a baseUrl via command line so my spec files dont have a hardcoded url for the app I am testing?

In Protractor, I am currently passing a flag in the command line that indicates what my URL is for the app I am testing. And now we are switching to Playwright, I want to do something similar. Since the same tests will be used to test the app in…
Kumar
  • 295
  • 1
  • 5
  • 10
13
votes
4 answers

Playwright before each for all spec files

I very new to Playwright. Due to my test suites, I need to login into my application before running each test. Inside a single spec file that is easy, I can simply call test.beforeEach. My issue is: I need to before the login before each test of…
Pelicer
  • 1,348
  • 4
  • 23
  • 54
13
votes
4 answers

Check if element is visible in Playwright

I'm using Playwright 1.15.2 for testing and facing a problem with elements' visibility. I want to check if a modal is visible on screen so I can close it. The modal starts with display:none and turns into display:block. Also, the modal informs…
JeanCHilger
  • 346
  • 1
  • 3
  • 12
1
2 3
99 100