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
13
votes
3 answers

Playwright JS - How to globally define/change timeout if element/selector not found?

Basically I want playwright to wait for each element 5 seconds if element not found. There is a way to change timeout individually as given below: await page.waitForSelector('h1', { timeout: 5000 }); But I want to define it globally only one time,…
Mairaj Ali
  • 151
  • 1
  • 2
  • 6
13
votes
3 answers

Ignore SSL errors with playwright code generation

I am using the jest-playwright library (https://github.com/playwright-community/jest-playwright) to perform end-to-end testing. In the jest.config.js file you can set an option to ignore SSL errors: contextOptions: { ignoreHTTPSErrors:…
kingkoen
  • 131
  • 1
  • 1
  • 3
13
votes
3 answers

How to wait for requests and validate responses using playwright?

This is my first time using playwright and I can't figure out how to wait for requests and validate responses. I've been using cypress for a quite a long time, and it was pretty easy to manage network requests. For example, I need to validate…
Vladimir Krygin
  • 439
  • 2
  • 6
  • 18
13
votes
2 answers

Disable Javascript in Playwright

Is it possible to define a browser with Javascript disabled to simulate how a crawler would view a page? There should be an option that can be passed.
Dietrich
  • 151
  • 1
  • 6
13
votes
3 answers

How to use installed version of chrome in Playwright?

I want to use chrome instead of chromium. I can achieve the same in puppeteer by providing executable path. In playwright it doesn't work as browser type argument supports only 'chromium, webkit, firefox' const { chromium } =…
Rajesh G
  • 473
  • 3
  • 6
  • 20
13
votes
3 answers

Puppeteer: How can I wait until a list is closed? How can I wait until an element is disappeared from the DOM?

Сase: There is a list in which you need to select an item, then it closes. When you click on another item the list does not have time to close. Finally there is one more click on another list element. await page.waitForSelector('.list'); await…
Oleksiy
  • 131
  • 1
  • 3
11
votes
5 answers

Is there a way to iterate over a
  • list in Playwright and click over each element?
  • I'm trying to iterate over a list of dynamic elements with Playwright, I've tried a couple of things already, but none have been working: await this.page.locator('li').click(); const elements = await this.page.locator('ul > li'); await…
    Gabriel Costa
    • 374
    • 1
    • 3
    • 16
    11
    votes
    3 answers

    How to pause the test script for 3 seconds before continue running it? Playwright

    I'm running a test called create admin. The test will first create admin, then check if the admin was created successfully. In the script, I have a part of code where I want to wait for 3 seconds before continuing because whenever the submit button…
    jialeee17
    • 601
    • 2
    • 7
    • 12
    11
    votes
    7 answers

    Playwright auto-scroll to bottom of infinite-scroll page

    I am trying to automate the scraping of a site with "infinite scroll" with Python and Playwright. The issue is that Playwright doesn't include, as of yet, a scroll functionnality let alone an infinite auto-scroll functionnality. From what I found on…
    alex_bits
    • 642
    • 1
    • 4
    • 14
    11
    votes
    4 answers

    Can I set the date for playwright browser

    When I write tests to run in playwright, I would like to be able to set the date that the browser believes it to be at the start of the test. Is there a way to achieve this using playwright?
    Billy Moon
    • 57,113
    • 24
    • 136
    • 237
    11
    votes
    2 answers

    How to add custom headers in Playwright

    headers["user-agent"] = fakeUa(); console.log(fakeUa()) let firstReq = true; page.route('**/*', route => { const request = route.request() //console.log(request.url(), JSON.stringify(request.headers())); if("x-j3popqvx-a" in…
    Amna Arshad
    • 767
    • 3
    • 10
    • 21
    10
    votes
    6 answers

    Playwright: how to wait until there is no animation on the page?

    I'm trying to figure out how to check whether the page has fully loaded in Playwright. await page.waitForLoadState('networkidle'); doesn't always work for me on Javascript-heavy sites. I've resorted to taking a screenshot base64, waiting 100 ms,…
    10
    votes
    1 answer

    How to set Playwright not automatically follow the redirect?

    I want to open a website using Playwright, but I don't want to be automatically redirected. In some other web clients, they have parameter link follow=False to disable automatically following the redirection. But I can't find it on Playwright. async…
    oon arfiandwi
    • 515
    • 1
    • 8
    • 21
    10
    votes
    2 answers

    Playwright e2e testing. What to do with oauth2 or email-passwordless authentication

    I am starting to do e2e tests with playwright. Most of the application requires to be authenticated. Automating this with a username/password mechanism is quite easy. The problem is that the app I want to test has only two authentication mechanisms:…
    10
    votes
    3 answers

    How do I access playwright test runner project info in a test?

    I'm writing a test to register users on my site. Using @playwright/test, I have defined several different projects in playwright.config.ts: { name: 'iPhone 12 Pro', use: devices['iPhone 12 Pro'], }, { name: 'iPhone 12 Pro Max', use:…
    Patrick Kenny
    • 4,515
    • 7
    • 47
    • 76