microsoft / playwright

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
https://playwright.dev
Apache License 2.0
66.45k stars 3.63k forks source link

[BUG] setDefaultTimeout not respected as expected #27691

Closed papaver closed 1 year ago

papaver commented 1 year ago

System info

Source code

will wait forever and not respect actionTimeout:

context.setDefaultTimeout(2);
page.setDefaultTimeout(2);

await page.locator('.Paginations .form-select')
  .click();

will correctly quit after 2 milliseconds:

await page.locator('.Paginations .form-select')
  .click({timeout:2});

Expected

When actionTimeout is set in the page or context it should be respected.

Actual

When actionTimeout is set in the page or context it defaults to waiting forever.

mxschmitt commented 1 year ago

I tried your code above and for me it was timing out after 2ms. Could you share maybe more of your project? Does this reproduce if you create a new project?

We also recommend to keep Playwright up to date, since you are using an old version, as per here.

papaver commented 1 year ago

appreciate your prompt response.

finally tracked it down to PWDEBUG=console being set in the environment. the docs are not clear that this also triggers debug mode where timeouts are reset to 0. i was setting this variable to be able to use the playwright object in the browser. seems weird to force this to reset all timeouts. in many cases not having elements available in the dom is ok, it makes the code cleaner than putting .count() and .all() wrappers everywhere.

the docs state:

When running in Debug Mode with PWDEBUG=console, a playwright object is available in the Developer tools console.

this seems to imply that debug mode and PWDEBUG=console are mutually exclusive.

is it possible to only have the playwright object in the browser without going into debug mode?