Modify HTTP Headers

Modify HTTP request and response headers in Endtest Web Tests to test auth flows, feature flags, geolocation, and custom server-side behavior.

Introduction

There are situations where you need to modify the HTTP headers for a Web Test.

Since Endtest uses webdrivers to control browsers and interact with elements, and because webdrivers don't offer a direct method for changing HTTP headers, you'll need to include a Chrome Extension like ModHeader in your Web Test to achieve this.

Steps

You can learn the basics of adding a Chrome Extension in your Web Test from the How to test Chrome Extensions chapter.

But the full process is explained here as well:

  1. Install the Chrome Extension Source Viewer in your own browser. You'll need it in order to download the ModHeader Chrome Extension.
  2. In your own Chrome browser, go to the Chrome Web Store page for the ModHeader Chrome Extension:
  3. Open the menu from the Chrome Extension Source Viewer and click on the Download as zip button.
  4. Upload that zip file to the Endtest Drive and copy the File Download URL.
  5. Go to the Advanced section of the Settings for your Test Suite and paste that copied File Download URL in the Add Chrome Extension input.
  6. Click on the Save button. Now your Test Suite will automatically load that ModHeader Chrome Extension when you run it.
  7. Add a Set Variable - Set Value step with the value chrome://extensions/.
  8. Add a Go to URL step for that variable.
  9. Add an Execute JavaScript step with this JavaScript code inside to enable Developer Mode:
    document.querySelector("body > extensions-manager").shadowRoot.querySelector("#toolbar").shadowRoot.querySelector("#devMode").shadowRoot.querySelector("#knob").click();
  10. Add another Execute JavaScript step with this JavaScript code inside to extract the Chrome Extension ID into a JavaScript variable:
    chromeExtensionID = document.querySelector("body > extensions-manager").shadowRoot.querySelector("#items-list").shadowRoot.querySelector("extensions-item").shadowRoot.querySelector("#extension-id").innerText.split(":")[1].trim();
  11. Add a Set Variable - Extract Value from JavaScript Variable step to extract the value from the chromeExtensionID JavaScript variable into an Endtest variable.
  12. Add a Go to URL step to go to this link: chrome-extension://{{$chromeExtensionID}}/src/popup_v1.html
  13. You can now start adding your custom Headers by using Write Text steps.

To find locators for the elements, you can add a Miscellaneous - Get Page Source step to extract and view the HTML of the ModHeader Chrome Extension page.

Here are some of those locators:

ElementXPath
1st Header Name input(//input[@name="header-name"])[1]
1st Header Value input(//input[@name="header-value"])[1]
2nd Header Name input(//input[@name="header-name"])[2]
2nd Header Value input(//input[@name="header-value"])[2]
Add Request Header button(//button[contains(@class, "mdc-button")])[1]
  1. After that, you can verify that the custom Headers were added by using a Go to URL step to go to a website that displays the Headers used by the browser.

Because this approach relies on the ModHeader Chrome Extension, you can only add or modify headers in a Web Test that runs on Chrome.

This chapter was written in June 2025. In the future, updates to the ModHeader Chrome Extension or the Chrome Extensions page may change their UI, which could cause the locators or JavaScript used here to stop working. You can still follow the same steps by identifying the updated locators in your own browser.