K
K
kos_dev2017-09-22 05:31:16
.NET
kos_dev, 2017-09-22 05:31:16

How to run Selenium Webdriver with proxy [C#]?

Hello.
I tried a lot of ways to run PhantomJS or ChromeDriver under a proxy, but all to no avail - web pages do not load.
If you have already implemented similar functionality - please help. Thank you all in advance for your replies.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Eremin, 2017-09-22
@EreminD

What exactly have you tried?
And why didn't the option work then:

ChromeOptions options = new ChromeOptions();
options.AddArguments("--proxy-server=http://user:[email protected]:8080");
IWebDriver Driver = new ChromeDriver(options);

R
RDavydenko, 2021-07-14
@RDavydenko

Use this ( https://github.com/RDavydenko/OpenQA.Selenium.Chro... )
Install the NuGet package:

Install-Package OpenQA.Selenium.Chrome.ChromeDriverExtensions -Version 1.1.0

Use for ChromeOptions :
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Chrome.ChromeDriverExtensions;
...
var options = new ChromeOptions();
    
//  Добавь свой HTTP-Proxy
options.AddHttpProxy(PROXY_HOST, PROXY_PORT, PROXY_USER, PROXY_PASSWORD);
    
var driver = new ChromeDriver(options); // или new ChromeDriver(AppDomain.CurrentDomain.BaseDirectory, options);
    
driver.Navigate().GoToUrl("https://whatismyipaddress.com/"); // Проверь свой IP

Instead of PROXY_HOST , PROXY_PORT , PROXY_USER , PROXY_PASSWORD use your proxy settings

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question