2

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();

umadik
  • 101
  • 2
  • 17
Büşra Duygu
  • 65
  • 1
  • 1
  • 5
  • 1
    Did you check this? https://stackoverflow.com/a/56436391 – umadik Dec 02 '21 at 07:53
  • yes but after downloading i didn't understand what to do. I placed msedgedriver.exe in my project's bin>debug file, but still got the same error. – Büşra Duygu Dec 02 '21 at 08:11
  • When I run the exe file it outputs like this: Starting MSEdgeDriver 96.0.1054.41 (ae6fee696dce50cb030935f67d6e6538d45a4a7a) on port 9515 Only local connections are allowed. Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping MSEdgeDriver safe. MSEdgeDriver was started successfully. – Büşra Duygu Dec 02 '21 at 08:13
  • Should it be a `gecko driver` instead of `MS Edge chromium driver`? – Sham Dec 02 '21 at 11:34
  • Your code and what the EXE is reporting do not match. The EXE says you are using the Edge driver, but the code you posted mentions FirefoxDriver. Are you sure you posted the right code? – Greg Burghardt Dec 07 '21 at 15:55
  • Are you sure the exe file is being built properly? – Greg Burghardt Dec 07 '21 at 15:55

0 Answers0