Chethana Hidogama
Chethana Hidogama

Reputation: 21

Proxy Authentication with chrome driver C#

I want to use proxy (HTTP proxy with user name and password) with my chrome driver and it doesn’t seems to be working in my C# application. It doesn’t use proxy when launching chrome browser.

Hope someone mighty help me

Thanks!

Sample Code:

string proxyUrl = String.Format(“http://{0}:{1}@{2}:{3}”, _proxy.textUsername, _proxy.textPassword,_proxy.textProxy, _proxy.numberProxyPort);

Proxy proxyObj = new Proxy()
{
IsAutoDetect = false,
Kind = ProxyKind.Manual,
HttpProxy = proxyUrl,
SslProxy = proxyUrl
};

options.AddArguments("–proxy-server="+ proxyUrl);
options.Proxy = proxyObj;
IWebDriver driver = new ChromeDriver(options);
driver.Navigate().GoToUrl("https://whatismyipaddress.com/");

Upvotes: 2

Views: 4736

Answers (2)

i7solar
i7solar

Reputation: 57

There's a lot of people who have been giving incorrect answers.

I've literally sat here for 2-3 hours and figured out how to do it after looking at multiple sites.

If you use proxy support, and you have an IP auth... you'll have to use a extension to grab the username/pw for auth... if it's an IP that works anywhere then you should be fine.

However if you do need to use the extension, it might not work with headless.

See below the code I used, p.HTTP proxy will be a proxy you pass in.

        Proxy p = new Proxy();
        p.IsAutoDetect = (false);

        p.HttpProxy = Proxy;
        p.SslProxy = Proxy;
        option.AddArguments("--proxy-server=http://" + p.HttpProxy);

Upvotes: 1

unickq
unickq

Reputation: 3295

Try to create own extension for Chrome. Here's the link if it's still reasonable Answer

Upvotes: 0

Related Questions