Injecting Page Scripts

You can run JavaScript code snippets inside the tested page, either when the page first starts loading, or after the page has finished loading.

Some use cases:

  • Set a cookie that hides a GDPR notice
  • Click a "Save" button during a test, so that the save request is available when loading a page archive

How to set up script injection

You can either set up scripts to inject when creating a page, or later on by clicking "edit" when viewing the page results.

Edit the page

Click "Show advanced" and then expand the "Inject Scripts" section.

Configuring advanced page settings

Select or create a script

There are two types of scripts.

  • Scripts that run before the page starts loading let you set preconditions or configuration for your page.

  • Scripts that run after the page finished loading allow you to script interactions that cause more data to be captured about your page. For example, you can use this to make sure certain requests are included in page archives.

Configuring injected JavaScript code on DebugBear

When you create or edit a script you'll see a modal were you can enter your code snippet.

Injected script content

Save your page changes

After saving the script, click "Update" to save the page.

Still need help? Contact for support.
DebugBear is a website monitoring tool built for front-end developers. Track performance metrics and Lighthouse scores in CI and production. Learn more.
© 2020 DebugBear Ltd