C# selenium 设置代理IP和常用参数设置

var cdSvc = ChromeDriverService.CreateDefaultService();
cdSvc.HideCommandPromptWindow = true;
//IWebDriver driver = new ChromeDriver(System.AppDomain.CurrentDomain.BaseDirectory.ToString());
var option = new ChromeOptions();
// option.AddArgument("--incognito"); // 影身模式
//option.AddArgument("headless");//设为无头模式
option.AddArgument("disable-infobars");//去掉提示:Chrome正收到自动测试软件的控制
option.AddArguments("--proxy-server=http://192.168.0.1:1123"); 

//这种设置无效 //option.AddArguments("--proxy-server=http://117.21.178.7:12150"); option.AddArguments("lang=zh_CN.UTF-8"); option.AddExcludedArgument("enable-automation"); option.AddAdditionalCapability("useAutomationExtension", false); //设置代理IP ip+port string ip =192.168.0.1:1123 Proxy proxy = new Proxy(); proxy.Kind = ProxyKind.Manual; proxy.IsAutoDetect = false; proxy.HttpProxy = ip; // proxy.HttpProxy =ip; //这里是http //proxy.SslProxy = ip; //这里是ssl option.Proxy = proxy; option.AddArgument("ignore-certificate-errors"); driver = new ChromeDriver(cdSvc, option);

 

C# selenium 设置代理IP和常用参数设置

上一篇:Windows 配置时间同步服务器以及配置时间同步间隔


下一篇:C# 获取当前程序的命名空间、方法名、类名