Playwright · Method
page.addInitScript
Installs JavaScript that runs in new page documents before the page's own scripts. It is useful for changing the page environment, such as making Math.random predictable.
Last updated
- Since
- v1.9
Syntax
page.addInitScript(script[, arg[, options]])In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.
SubscribeRelated
browserContext.addInitScript()page.exposeFunction()page.evaluate()