我想听听 phantomjs selenium 驱动程序在 c# 中生成的流量。不幸的是,下面的代码不起作用!
PhantomJSOptions phoptions = new PhantomJSOptions();
phoptions.AddAdditionalCapability("proxy", "http://localhost:9999");
driver = new PhantomJSDriver(phoptions);
任何人都可以帮助我有什么问题!
提前致谢
Proxy proxy = new Proxy();
proxy.HttpProxy = string.Format("127.0.0.1:9999");
var service = PhantomJSDriverService.CreateDefaultService();
service.ProxyType = "http";
service.Proxy = proxy.HttpProxy;
IWebDriver driver = new PhantomJSDriver(service);
Some quick testing showed this work for me.
您可以使用CapabilityType
该类来设置代理功能。这是上面代码的修改版本:
PhantomJSOptions phoptions = new PhantomJSOptions();
phoptions.AddAdditionalCapability(CapabilityType.Proxy, "http://localhost:9999");
driver = new PhantomJSDriver(phoptions);
这对我有用。Arran 的回答对我不起作用。出于某种原因,我的PhantomJSDriverService
班级没有ProxyType
orProxy
成员。