Endtest

Endtest

›Web Tests

Web Tests

  • How to create Web Tests
  • Finding elements in Web Applications
  • How to execute Web Tests
  • Assertions for Web Tests
  • IF Statements for Web Tests
  • Web Applications with restricted access
  • How to test in iframes
  • How to test in multiple tabs
  • How to test File Uploads
  • How to test File Downloads
  • How to test Emails
  • How to test PDF files
  • How to test Chrome Extensions
  • Dealing with reCAPTCHA
  • Dealing with Dynamic Locators
  • Dealing with Canvas Elements
  • Performing a Drag and Drop
  • Execute JavaScript
  • Modify HTTP Headers
  • Testing WebRTC Applications
  • How to scroll in Web Tests
  • How to test Checkboxes
  • How to test Dropdowns
  • Dealing with Sessions
  • Web Crawler
  • Export Web Tests
  • Migrating from Selenium

Mobile Tests

  • How to create Mobile Tests
  • Finding elements in Mobile Applications
  • How to execute Mobile Tests
  • Assertions for Mobile Tests
  • IF Statements for Mobile Tests
  • How to scroll in Mobile Tests
  • Performing Complex Gestures

Advanced

  • Variables
  • Waits
  • Endtest API
  • Scheduler
  • Drive
  • Adding Collaborators
  • Computer Vision
  • Importing Test Cases
  • Using Loops
  • Data-driven Testing
  • Send API Requests
  • Read SMS
  • Execute SQL queries
  • Self-Healing Tests
  • Email Notifications
  • Slack Notifications
  • PagerDuty Notifications
  • Webhook Notifications
  • Automatic Backup
  • Advanced Settings
  • Multiple environments
  • How to stop a test
  • Utilities
  • Utilities API
  • Team
  • On-Premises

Integrations

  • Atlassian Jira
  • Slack
  • PagerDuty
  • Microsoft Teams
  • Discord
  • Mattermost
  • Jenkins
  • GitHub
  • Azure DevOps
  • GitLab
  • TeamCity
  • CircleCI
  • TravisCI
  • Bitbucket
  • Heroku
  • Bamboo Server
  • Test Case Management
  • SSO
  • BrowserStack
  • Sauce Labs

Modify HTTP Headers

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:
  • https://chromewebstore.google.com/detail/modheader-modify-http-hea/idgpnmonknjnojddfkpgkljpfnnfcklj
  1. Open the menu from the Chrome Extension Source Viewer and click on the Download as zip button.
  2. Upload that zip file to the Endtest Drive and copy the File Download URL.
  3. 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.
  4. Click on the Save button. Now your Test Suite will automatically load that ModHeader Chrome Extension when you run it.
  5. Add a Set Variable - Set Value step with the value chrome://extensions/.
  6. Add a Go to URL step for that variable.
  7. 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();
  1. 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();
  1. Add a Set Variable - Extract Value from JavaScript Variable step to extract the value from the chromeExtensionID JavaScript variable into an Endtest variable.
  2. Add a Go to URL step to go to this link: chrome-extension://{{$chromeExtensionID}}/src/popup_v1.html
  3. 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.

← Execute JavaScriptTesting WebRTC Applications →
  • Introduction
  • Steps
© Endtest Inc.