I want to change my ip address and visit a site using proxy ip, but in the code block
IWebDriver driver = new FirefoxDriver(firefoxDriverService, firefoxOptions);
It gives an error when it comes to the line. I would greatly appreciate your help. Thank you in advance.
My code block :
FirefoxDriverService firefoxDriverService = FirefoxDriverService.CreateDefaultService();
firefoxDriverService.HideCommandPromptWindow = true;
FirefoxOptions firefoxOptions = new FirefoxOptions();
string proxyIp = "xxx.xxx.xxx.xxx";
string proxyUsername = "my_user_name";
string proxyPassword = "my_password";
string proxyPort = "xxxx";
var proxy = new
{
Ip = proxyIp,
Username = proxyUsername,
Password = proxyPassword,
Port = proxyPort
};
string PROXY = proxy.Ip + ":" + proxy.Port;
Proxy pro = new Proxy();
pro.Kind = ProxyKind.Manual;
pro.IsAutoDetect = false;
pro.HttpProxy = PROXY;
pro.FtpProxy = PROXY;
pro.SslProxy = PROXY;
firefoxOptions.Proxy = pro;
firefoxOptions.AddArgument("ignore-certificate-errors");
IWebDriver driver = new FirefoxDriver(firefoxDriverService, firefoxOptions);
var wait = new WebDriverWait(driver, new TimeSpan(0, 0, 60)); //Bekleme süresi
driver.Navigate().GoToUrl("https://www.busra.com/");
driver.Manage().Window.Maximize(); //sayfayı büyüt
//AutoIt kütüphanesi kullanarak username ve password bilgilerinin girilmesi
AutoItX.AutoItSetOption("WinTitleMatchMode", 2);
AutoItX.WinWaitActive("- Firefox", "", 10);
AutoItX.WinActivate("- Firefox");
AutoItX.Send(proxyUsername);
AutoItX.Send("{TAB}");
AutoItX.Send(proxyPassword);
AutoItX.Send("{ENTER}");
AutoItX.WinWaitActive("Save password for ", "", 10);
AutoItX.WinActivate("Save password for ");
AutoItX.Send("{TAB}");
AutoItX.Send("{SPACE}");
var element = wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(By.Id("search_button")));
//Search butonuna tıkla
element.Click();