question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] playwright waitForNavigation problem with firefox [headless, headed] but is working via [firefox-mode-debug, chromium, webkit]

See original GitHub issue
  • playwright version: 1.16.3
  • operating system: locally-> windows, cicd -> azure
  • node version: 15.0.1
  • npm version: 7.9.0
  • browser: error only in firefox: [headless, headed], no error in firefox --debug, chromium,webkit
  • auth tool: keycloak

I can login only via [firefox-mode-debug, chromium, webkit] but not via firefox [headless, headed]:

url: https://dmitrygozman.fieldcode.com/ user: dgozman.demo@gmail.com pass: Dgozman123

package.json
{
  "devDependencies": {
    "@playwright/test": "^1.16.3",
    "expect-playwright": "^0.8.0",
    "ua-parser-js": "^1.0.2"
  },
  "dependencies": {
    "playwright": "^1.16.3"
  }
}


just_login_dgozman.spec.js

process.env.baseurl = 'https://dmitrygozman.fieldcode.com/';
const {test, expect} = require('@playwright/test');
const auth_storage_path = 'storage_auth.json';

test('login', async ({page}) => {
  await page.goto(process.env.baseurl);
  const field_username  = '[id="username"]';
  const field_password  = '[id="password"]';
  const button_login    = '[id="fc-login-button"]';
  const value_username  = 'dgozman.demo@gmail.com';
  const value_password  = 'Dgozman123';

  await page.click(field_username);
  await page.fill(field_username, value_username);
  await page.click(field_password);
  await page.fill(field_password, value_password);

  await Promise.all([
    //page.waitForNavigation({url: process.env.baseurl}),                         //works in:[chromium,webkit, firefox-mode-debug]. Problems in firefox:[headless, headed].
    //page.waitForNavigation({url: process.env.baseurl, waitUntil: "load"}),      //works in:[chromium,webkit, firefox-mode-debug]. Problems in firefox:[headless, headed].
     page.waitForURL(process.env.baseurl),                                    //suggestion from dgozman
     page.click(button_login),
  ]);
  //save auth:
  const myContext = page.context();
  process.env.STORAGE = null;
  const storage = await myContext.storageState({path: auth_storage_path});
  process.env.STORAGE = JSON.stringify(storage);
  JSON.parse(process.env.STORAGE);
});

test.describe("just check login was success", () => {
  test.use({storageState: auth_storage_path});
  test('check_login_success', async ({page}) => {
    await page.goto(process.env.baseurl);
    const button_search = 'button[data-ui-test="ticketPoolSearchButton"]';
    //await page.waitForSelector(button_search);
    await expect(page.locator(button_search)).toBeVisible(); //suggestion from dgozman
  });

});

Same test run with different browsers, works in: chromium, webkit but not if firefox. But it works in firefox debug modus

Console after run with chromium. It works !!! test npx playwright test mydemos/login/just_login.spec.js --browser=chromium

PS C:\workspace\microservice\PlaywrightUiTests> npx playwright test mydemos/login/just_login.spec.js --browser=chromium
Using config at C:\workspace\microservice\PlaywrightUiTests\playwright.config.js
Running 2 tests using 1 worker
  ok [chromium] › mydemos\login\just_login.spec.js:4:1 › login (4s)
  ok [chromium] › mydemos\login\just_login.spec.js:24:3 › just check login was success › check_login_success (3s)
  2 passed (9s)

Console after run with webkit. It works !!! npx playwright test mydemos/login/just_login.spec.js --browser=webkit

PS C:\workspace\microservice\PlaywrightUiTests> npx playwright test mydemos/login/just_login.spec.js --browser=webkit
Using config at C:\workspace\microservice\PlaywrightUiTests\playwright.config.js
Running 2 tests using 1 worker
  ok [webkit] › mydemos\login\just_login.spec.js:4:1 › login (8s)
  ok [webkit] › mydemos\login\just_login.spec.js:24:3 › just check login was success › check_login_success (5s)
  2 passed (15s)

Console after run with firefox. It fails!!! npx playwright test mydemos/login/just_login.spec.js --browser=firefox

PS C:\workspace\microservice\PlaywrightUiTests> npx playwright test mydemos/login/just_login.spec.js --browser=firefox
Using config at C:\workspace\microservice\PlaywrightUiTests\playwright.config.js

Running 2 tests using 1 worker

  x  [firefox] › mydemos\login\just_login.spec.js:4:1 › login (30s)
  ok [firefox] › mydemos\login\just_login.spec.js:24:3 › just check login was success › check_login_success (14s)


  1) [firefox] › mydemos\login\just_login.spec.js:4:1 › login ======================================

    Timeout of 30000ms exceeded.

    page.waitForNavigation: Navigation failed because page was closed!
    =========================== logs ===========================
    waiting for navigation to "/" until "load"
      navigated to "https://mytenat.myweb.com/auth/realms/mytenat/login-actions/authenticate?session_code=..."
      navigated to "https://mytenat.myweb.com/auth/realms/mytenat/login-actions/authenticate?execution=....."
    ============================================================

      15 |   await Promise.all([
      16 |     //page.waitForNavigation({url: '/'}),     //works in:[chromium,webkit, firefox-mode-debug]. Problems in firefox:[headless, headed].                       
    > 17 |     page.waitForNavigation({url: '/', waitUntil: "load"}),  //works in:[chromium,webkit, firefox-mode-debug]. Problems in firefox:[headless, headed].
         |          ^
      18 |     page.click(button_login)
      19 |   ]);
      20 | });

        at C:\workspace\microservice\PlaywrightUiTests\mydemos\login\just_login.spec.js:17:10

  Slow test: [firefox] › mydemos\login\just_login.spec.js (44s)

  1 failed
    [firefox] › mydemos\login\just_login.spec.js:4:1 › login =======================================
  1 passed (51s)

Console after run with firefox --debug. It works!!! npx playwright test mydemos/login/just_login.spec.js --browser=firefox --debug

PS C:\workspace\microservice\PlaywrightUiTests> npx playwright test mydemos/login/just_login.spec.js --browser=firefox --debug
Using config at C:\workspace\microservice\PlaywrightUiTests\playwright.config.js

Running 2 tests using 1 worker

  ok [firefox] › mydemos\login\just_login.spec.js:4:1 › login (26s)
  ok [firefox] › mydemos\login\just_login.spec.js:24:3 › just check login was success › check_login_success (12s)

  Slow test: [firefox] › mydemos\login\just_login.spec.js (38s)

  2 passed (41s)

When I run debug modus and I press play button (instead debug line by line) doesn’t log as well. Looks like the fill the logIn information is too fast in firefox

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
aslushnikovcommented, Dec 27, 2021

Looks like Playwright is just too fast at filling in these fields. Not a bug!

2reactions
yury-scommented, Dec 21, 2021

When I run debug modus and I press play button (instead debug line by line) doesn’t log as well. Looks like the fill the logIn information is too fast in firefox

It looks like the login fields appear on the screen, playwright fills in the user name and the DOM tree of the page gets rebuilt before playwright types in the password. Try recording trace, it may give you some insight (though I was not able to reproduce it with tracing on, apparently because it slows down the entire script a bit).

Read more comments on GitHub >

github_iconTop Results From Across the Web

[BUG] playwright waitForNavigation problem with firefox ...
[BUG] playwright waitForNavigation problem with firefox [headless, headed] but is working via [firefox-mode-debug, chromium, webkit] #10752.
Read more >
Configuration | Playwright - CukeTest
Playwright Test provides options to configure the default browser, context and page fixtures. For example there are options for headless, viewport and ......
Read more >
4 - Playwright Setup & First Script - Launch Chromium, Firefox ...
In this video, I have explained how to setup Playwright with Browser binaries and we will write our first script to launch the...
Read more >
playwright._impl._api_types.error: execution context was ...
I came into this issue today, and found that this problem occurs in this case: ... Note: chrome and webkit works, firefox fails...
Read more >
Browser checks | hyperping documentation
... using Node.js' Puppeteer and Playwright APIs to run headless browsers for ... you to automate the Chromium, Webkit and Firefox browsers using...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found