Tim*_*Tim 7 c# selenium webdriver selenium-firefoxdriver
如果您的代理服务器需要身份验证,则在下面的代码中设置代理服务器参数,然后FireFox将带来身份验证对话框,基本上您无法自动填写它.那么无论如何设置USERNAME和PASSWORD?
FirefoxProfile profile = new FirefoxProfile();
String PROXY = "192.168.1.100:8080";
OpenQA.Selenium.Proxy proxy = new OpenQA.Selenium.Proxy();
proxy.HttpProxy=PROXY;
proxy.FtpProxy=PROXY;
proxy.SslProxy=PROXY;
profile.SetProxyPreferences(proxy);
FirefoxDriver driver = new FirefoxDriver(profile);
Run Code Online (Sandbox Code Playgroud)
如果您尝试将代理字符串格式化为类似的东西http://username:pass@192.168.1.1:8080
您会收到字符串无效的错误.所以我想知道必须有一种实现这一目标的方法.
任何帮助,将不胜感激.
您可以做的是创建一个配置文件并将身份验证数据保存在其中。如果您的配置文件名为“webdriver”,您可以在初始化时从代码中选择它:
ProfilesIni allProfiles = new ProfilesIni();
FirefoxProfile profile = allProfiles.getProfile("WebDriver");
profile.setPreferences("foo.bar",23);
WebDriver driver = new FirefoxDriver(profile);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
11182 次 |
最近记录: |