Monday, August 3, 2020

How to change IP address time to time from selenium C#


  1.  [TestMethod]
  2.         public void ChromOptions()
  3.         {

  4.             string[] proxies = { "206.198.131.142:80", "51.81.112.164:5836" };

  5.             for (int i = 0; i < proxies.Length; i++)
  6.             {
  7.                 ChromeOptions options = new ChromeOptions();
  8.                 options.AddArguments("--proxy-server="+proxies[i]+"");
  9.                 driver = new ChromeDriver(@"C:\ChromeDriver1\", options);
  10.                 driver.Navigate().GoToUrl("https://whatismyipaddress.com/");

  11.             }
  12.         }

Above is a C# code to switch your browser IP.
At line 5 you have to give a list of working proxy IP and the PORT list as an array.

Thats it.