[英]Set proxy in PhantomJS
I'm having a bit of an issue setting a proxy with PhantomJS, I try to do like this way: 我在用PhantomJS设置代理时遇到了一些问题,我尝试这样做:
OpenQA.Selenium.Proxy proxy = new OpenQA.Selenium.Proxy();
proxy.HttpProxy = p;
PhantomJSOptions des = new PhantomJSOptions();
des.AddAdditionalCapability(CapabilityType.Proxy, proxy);
(p is just a string in a loop for a proxy list, and yes p is getting set correctly) (p只是一个用于代理列表的循环中的字符串,是的,p的设置正确)
But it says element not found when I go to find something on the page because it's navigating to the URL, but the page source it returns is blank as seen here: http://prntscr.com/6hcmz4 但是它说当我去页面上查找某些内容时找不到元素,因为它正在导航到URL,但是它返回的页面源是空白的,如下所示: http : //prntscr.com/6hcmz4
Updated Code #1 - No Luck 更新的代码1-不走运
PhantomJSDriverService service = PhantomJSDriverService.CreateDefaultService();
service.IgnoreSslErrors = true;
service.LoadImages = false;
service.Proxy = p;
using (var driver = new PhantomJSDriver(service))
Any ideas guys? 有想法吗?
I had the same problems, with java client but it does not matter. 我在使用Java客户端时遇到了同样的问题,但这没有关系。 The fix that i've found is to pass capatibilites via CLI
我发现的解决方法是通过CLI传递Capatibilites
ArrayList<String> cliArgsCap = new ArrayList<String>(); cliArgsCap.add(String.format("--proxy=%s:%s", proxy.getHost(), proxy.getPort())); cliArgsCap.add(String.format("--proxy-auth=%s:%s", proxy.getUsername(), proxy.getPassword())); cliArgsCap.add("--webdriver=4444"); cliArgsCap.add("--proxy-type=http"); desiredCapabilities.setCapability("phantomjs.cli.args", cliArgsCap);
The main point is to pass cliArgsCap.add("--webdriver=4444"); 要点是传递cliArgsCap.add(“-webdriver = 4444”); cause there are some issues regarding this https://github.com/ariya/phantomjs/issues/12420 https://github.com/ariya/phantomjs/issues/11619
导致与此有关的一些问题https://github.com/ariya/phantomjs/issues/12420 https://github.com/ariya/phantomjs/issues/11619
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.