简体   繁体   中英

C# selenium/phantomjs set global proxy

I need to setup phantomjs to use a proxy. I have found many examples for java, javascript/node.js, etc. But none for c# using selenium. 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.

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', '', '');")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM