4

I have following code.

IWebDriver webDriver = null;

System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startinfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "ForceBindIP64.exe";
startInfo.Arguments = " -i 10.1.1.111 \"C:\\Program Files\\Mozilla Firefox\\firefox.exe\"";
process.StartInfo = startInfo;
process.Start();
process.WaitForExit();

System.Uri = new System.Uri("http://localhost:7055/hub");

Thread.Sleep(5000);

webDriver = new RemoteWebDriver(uri, options);

What I'm trying to do here is I'm trying to bind a particular IP using ForceBindIP with a browser instance opened up by the selenium Firefox driver which is actually the geckodriver. At webDriver = new RemoteWebDriver(uri, options); I'm getting following exception errors.

enter image description here

enter image description here

enter image description here

I understand I'm getting above errors may be because the port number I defined could be wrong or I will have to open up the browser using the Firefox Driver. Could be something else as well. Does anyone have a solution for this. I will have to bind the instance of the browser opened by the driver gets binded to a particular IP through ForceBindIP.

joekevinrayan96
  • 564
  • 10
  • 25

2 Answers2

0

It is not possible to start firefox browser using ForcebindIp. because firefox uses the first active ip in the system. Since it is not possible to start the driver with focebindip, instead of trying to start it this way, you can use your internet by turning your other internet into a proxy and adding a proxy in firefox.

0

You can try to set this Firefox setting according to ForceBindIP documentation:

Firefox requires the about:config?filter=browser.launcherProcess.enabled preference set to false, otherwise ForceBindIP attaches to the launcher and not the actual program.

According to Selenium grid documentation there are several ports that should be exposed in order to allow the communication between all grid components. You can use a powershell command to test the connectivity.

powershell.exe tnc localhost -port 7055 

In several posts I see the hubURL is like this one (has wd before hub). I guess you have changed the default port and maybe URL:

hubUrl = "http://localhost:4444/wd/hub

I am not sure this is applicable to your use case, but you can connect to already running Firefox instance:
How to connect to an existing firefox instance using selenium(python)
How to use/attach an existing browser using Selenium?
Selenium webdriver - How to connect to the same firefox instance open by Visual Studio using C#

K. B.
  • 3,342
  • 3
  • 19
  • 32
  • I'm just a middleman, so I am not really qualified to decide whether this solves the problem or not; but it demonstrates research and links to official sources, so gets the bounty for putting down the effort to create a detailed answer. – tripleee Feb 09 '23 at 19:08