[英]How to correctly set up a proxy with Selenium C# PhantomJSDriver?
How do I correctly set up a proxy with Selenium C# PhantomJSDriver in a C# console application?如何在 C# 控制台应用程序中使用 Selenium C# PhantomJSDriver正确设置代理?
I have looked high/low at all online docs and similar post with no success:我在所有在线文档和类似的帖子中都看高/低,但没有成功:
Here's my code:这是我的代码:
var options = new PhantomJSOptions();
options.AddAdditionalCapability(CapabilityType.Proxy,"123.456.748.99:80");
IWebDriver driver = new PhantomJSDriver(options);
Running this code I get the following error(s):运行此代码,我收到以下错误:
**ERROR: Unexpected error. **错误:意外错误。 TypeError - undefined is not an object (evaluating 'proxyCapability["proxyType"].toLowerCase') TypeError - undefined 不是一个对象(评估 'proxyCapability["proxyType"].toLowerCase')
PhantomJSDriverService service = PhantomJSDriverService.CreateDefaultService();
service.AddArgument(string.Format("--proxy-auth={0}:{1}", proxyUsername, proxyPassword));
service.AddArgument(string.Format("--proxy={0}:{1}", proxyAddress, proxyPort));
IWebDriver driver = new PhantomJSDriver(service);
in service you have more options to add if you need.在服务中,您可以根据需要添加更多选项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.