How do you set the port for ChromeDriver in Seleni

2019-05-22 13:46发布

As some background, I'm playing around with BrowserMob proxy and I am getting blocked by the port settings. So I'd like to know how to set a port by myself.

 Server srv = new Server(@"C:\BMob\browsermob\bin\browsermob-proxy.bat");
 srv.Start();
 Client cln = srv.CreateProxy();
 cln.NewHar("BOWZA"); 
 ChromeOptions co = new ChromeOptions();
 Proxy  seleniumProxy = new Proxy { HttpProxy = cln.SeleniumProxy };
 co.Proxy = seleniumProxy;
 ChromeDriver cDriver = new ChromeDriver(co);
// What do I do now...?

I just failed to find anything documenting this, sorry

1条回答
霸刀☆藐视天下
2楼-- · 2019-05-22 14:11

This should work:

ChromeDriverService service= ChromeDriverService.CreateDefaultService(DRIVER_PATH);
service.Port = <PORT>;
IWebDriver WebDriver = new ChromeDriver(service);
查看更多
登录 后发表回答