作为一些背景,我正在使用BrowserMob代理,并且被端口设置阻止了。所以我想知道如何自己设置端口。
Server srv = new Server(@"C:BMobbrowsermobbinbrowsermob-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...?
我只是找不到任何记录这一点的东西,对不起
这应该有效:
ChromeDriverService service= ChromeDriverService.CreateDefaultService(DRIVER_PATH);
service.Port = <PORT>;
IWebDriver WebDriver = new ChromeDriver(service);
这对
我有用。我也在使用WebDriverManager
ChromeDriverService chromeDriverService = new ChromeDriverService.Builder().usingPort(DesiredPortNumber).build();
然后在初始化新驱动程序时将其用作参数
new ChromeDriver(chromeDriverService , BrowserOptionsManager.getChromeOptions());