The following C# is meant to open a selenium driver and connect to a proxy with authentication. The chrome alert pops up on driver.Navigate().GoToUrl(...) and cannot get past. This means I can't deal with the alert in the try{}catch{}.
How can I authenticate the proxy?
The closest I've found so far has been this post
using System;
using System.Net;
using System.Net.Sockets;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Support.UI;
namespace ConnectProxy
{
internal class Program
{
private static void Main()
{
var proxy = new
{
Ip = "XXX",
Username = "YYY",
Password = "ZZZ",
Port = "80"
};
string PROXY = proxy.Ip + ":" + proxy.Port;
Proxy pro = new Proxy();
pro.HttpProxy = PROXY;
pro.FtpProxy = PROXY;
pro.SslProxy = PROXY;
ChromeOptions options = new ChromeOptions();
options.Proxy = pro;
IWebDriver driver = new ChromeDriver(options);
driver.Navigate().GoToUrl("https://" + proxy.Username + ":" + proxy.Password + "@" + "whatismyipaddress.com/");
try
{
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(15));
wait.Until(c => c.FindElement(By.Id("content-section")));
IAlert alert = driver.SwitchTo().Alert();
alert.SetAuthenticationCredentials(proxy.Username, proxy.Password);
alert.Accept();
}
catch { }
}
}
}