TestProject Forum
Powered by leading experts in the test automation community

Inject custom request headers for all page loads

I’m prototyping some SDK tests against microservices that deliver their own web UI. To do this I need to simulate some of the request headers that get passed to these microservices behind our gateway proxy. The most important header is the Authorization header which contains a bearer token (JWT) which would be used for authentication.

Can I pass these custom headers using TestProject somehow, or do I need to run my tests through some kind of external proxy like browsermod-proxy?

Hello @zblocker
Are you using the recorder or coded tests with our SDK?

We’ll be using the recorder and online tests in a completely different way from our SDK tests.

The online tests will be created by our QA team who may or may not use the recorder. They will use a complete test environment including gateway reverse proxy for their tests, so there will be no need for injection of bearer token as I have described.

The SDK tests will be written in code (either C# or Python; I’m trying out both…) They will be versioned as a test project which will be executed at build time as part of our automated pipeline. The environment will be a Dockerized integration test environment with lots of mocked services, etc. We do not plan on using our gateway reverse proxy here, so it is necessary to create mock bearer tokens and inject them into our requests, to simulate a logged-in user experience.

Hello @zblocker, thanks for reaching out.

for setting custom headers or using an external proxy like browermod-proxy, you will need to set custom/desired capabilities to the driver.

Currently, setting custom capabilities supported in Python and Java SDKs, and not supported in C# SDK. we are going to add this to C# SDK soon as well, you can find them here:

an example of Python coded test using BMP as a proxy, you can find in our previous conversation: