Playwright headless waiting issues

86 Views Asked by At

I'm tired of 'unexpected' issues and different sorprises using Playwright on my Project. I don't understand what is happening whith the default timeouts between the steps of my test cases.

First of all:

  1. the main issue is that it seems 'headless' mode is running SO FAST and some steps like "waits for be visible" of my test cases are failing, because the urls are loading so fast or they are not. This is strange and umcofortable because the consistency of my test results is not stable, with the browser they passed, headless they failed or passed idk why. (If you have any information it would be usefull♥)

  2. I'm trying to use the "waitfor" functions to say "stop playwright, take it easy bro" but.... It doesn't work. I guess I'm not using this functionalities correctly, but I would to share with you, and have some feedback about this behaviors of Playwright and the headless executions. I repeat, this is working on headed mode (browser on) but not headless (github executions for example)

Example:

        await navbars.topsearchBar.fill(myNumbertoString);
        await page.keyboard.press('Enter'); // I'M FILLING MY SEARCHBAR WITH A STRING AND I'M PRESSING ENTER

HERE THE APPLICATION IT'S LOADING A NEW URL, A NEW "WINDOW" SO, I GUESS I COULD ORDER TO PLAYWRIGHT "HEY, WAIT UNTILL THIS ELEMENT IS VISIBLE TO CONTINUE..." SO I'M DOING:

        await newView.dataContainer.waitFor( { state: 'visible' } ); // This is a simple container
        await page.waitForLoadState('domcontentloaded'); // I guess domcontentloaded as the word explains, I will be waiting untill the dom is completed to move forward
        await expect(newView.taskCompleted).not.toBeNull(); 

What happens? It happens that** headless execution** is not recognizing the step "wait for state visible". The execution is not waiting, is just "failing" and stopping the test case. It's really fast.

** How could I improve this situations with the WaitFor options? How should I consider to use the waits in Playwright? There's something regarding the parallel executions that is blocking my executions? Or something like that? **

Okey, that's all. Thank you very much and hope I got some answers to be able to learn from each other!

I'm trying to order playwright to WAIT untill a component is visible, to continue with the test case and not to stop if the component is not visible. Because it's obviusly the component is not visible, the DOM is loading...

What happened? I'm geting inconsistent wait errors in headless mode.

0

There are 0 best solutions below