[英]C# selenium/phantomjs set global proxy
I need to setup phantomjs to use a proxy.我需要设置 phantomjs 才能使用代理。 I have found many examples for java, javascript/node.js, etc. But none for c# using selenium.
我找到了很多关于 java、javascript/node.js 等的例子。但是没有一个使用 selenium 的 c# 例子。 I need to set a global proxy and be able to change it without restarting the driver.
我需要设置一个全局代理并且能够在不重新启动驱动程序的情况下更改它。 I believe it would be under driver.ExecutePhantomJS() but I also cant find what phantomjs script I would run to change the global proxy.
我相信它会在 driver.ExecutePhantomJS() 下,但我也找不到我将运行什么 phantomjs 脚本来更改全局代理。
When creating the service:创建服务时:
OpenQA.Selnium.Proxy myproxy = new Proxy();
myproxy.httpProxy = ip +":"+port;
driverservice.AddAdditionalCapability(CapabilityType.Proxy, myproxy);
After driver is running to change the proxy:在驱动程序运行以更改代理后:
driver.ExecutePhantomJS("phantom.setProxy('"+ip+"', "+port+", 'http', '', '');")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.