I have a scenario wherein I need to provide Authorization credentials before navigating to a webpage.
After going through the documentation provided here https://docs.telerik.com/teststudio/testing-framework/write-tests-in-code/advanced-topics-wtc/using-the-http-proxy I thought of using HttpProxy to intercept the request and inject "Authorization" header in the Request pipeline.
For some reason I am not able to see the HTTP headers that I am trying to inject. Am I doing something wrong here?
My function looks like this
public void NavigateWithCredentils(Uri navigateUrl)
{
RequestListenerInfo li = new RequestListenerInfo(AddCredentials);
Telerik.Manager.Http.AddBeforeRequestListener(li);
Telerik.ActiveBrowser.NavigateTo(navigateUrl);
Telerik.Manager.Http.RemoveBeforeRequestListener(li);
}
private void AddCredentials(object sender, HttpRequestEventArgs e)
{
if (e.Request.Headers.GetValues("Authorization") == null)
{
e.Request.Headers.Add("Authorization", "Basic realusername:realpassword");
}
}
Note: UseHttpProxy is already set to true in the Initialization code.