It is possible to set the timeout for every method that accepts the timeout setting using:
browserContext.setDefaultTimeout(timeout)
"browserContext" may be slightly preferable to the "page" equivalent as it's set across the whole browserContext. You can always use the page setting if you want to override your broader browserContext setting.
If you want a different timeout for navigations than other methods, perhaps when simulating slow connection speeds, you can also set:
browserContext.setDefaultNavigationTimeout(timeout)
and that will take priority for navigations.
When using the Playwright Test Runner you can set the timeout globally for whole tests by creating a playwright.config.js file.
There is documentation on the specific timeout setting here:
https://playwright.dev/docs/test-intro#use-test-hooks
but a simplified version of their example is:
// playwright.config.js
module.exports = {
// Each test is given 30 seconds
timeout: 30000,
use: {
// Configure browser and context here
},
};