Creating Http request or proxy authentication to access a site using a token

Viewed 76
public void Setup()
{
    _driver = Driver.GenerateWebDriver(browser, "local");
    var network = _driver.Manage().Network;
    network.AddRequestHandler(new NetworkRequestHandler
    {
        RequestMatcher = data => data.Url.Contains("www-stage.ibselectronics.com"),
            RequestTransformer = data =>
            {
                if (data.Method == "POST")
                {
                    var plainTextBytes = Encoding.UTF8.GetBytes(data.PostData);
                    var base64String = Convert.ToBase64String(plainTextBytes);
                    data.PostData = base64String;
                }
                data.Headers["CF-Access-Client-Id"] = "token here.access";
                data.Headers["CF-Access-Client-Secret"] = "token here";
                return data;
            },
    });
    Task task = network.StartMonitoring();
    _driver.Navigate().GoToUrl(baseUrl);
    task.Wait();
}

this is my code I put it on setup so that before the browser will open this code will be execute but I encounter this error "One or more errors occurred. (Unexpected error creating WebSocket DevTools session.)" hope someone there will help any advice on how this will be execute or there is another way to post access a site using http header request ?

0 Answers
Related