How to set the PhantomJSOptions in Selenium for pr

2019-08-19 03:29发布

问题:

Using Selenium and the web driver to drive phantomjs as part of a web scraping project. From the "Known Issues" for Windows at PhantomJS, it is suggested that the proxy-type be set to "none" to speed up network performance.

I tried the following:

PhantomJSOptions options = new PhantomJSOptions();
options.AddAdditionalCapability("proxy", "{proxyType:none}");

However, this sets proxy to a string and I think I need a json object. Can someone show me how to do this correctly?

回答1:

Use the driver service to set options:

var phantomJSDriverService = PhantomJSDriverService.CreateDefaultService(phantomJsDir);
phantomJSDriverService.ProxyType = "none";
var driver = new PhantomJSDriver(phantomJSDriverService);