无法设置Firefox配置文件&;代理设置&;Java中的身份验证
尊敬的Selenium Webdriver大师 为了在使用Selenium Webdriver 2启动Firefox时发现FireBug,我做了以下Firefox配置文件设置更改:无法设置Firefox配置文件&;代理设置&;Java中的身份验证,java,selenium,selenium-webdriver,Java,Selenium,Selenium Webdriver,尊敬的Selenium Webdriver大师 为了在使用Selenium Webdriver 2启动Firefox时发现FireBug,我做了以下Firefox配置文件设置更改: public static void main(String[] args) { File fireBugFile = new File("C:/selenium-ide-1.9.0.xpi"); FirefoxProfile firefoxProfile = new FirefoxProfile(
public static void main(String[] args)
{
File fireBugFile = new File("C:/selenium-ide-1.9.0.xpi");
FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.addExtension(fireBugFile);
firefoxProfile.setPreference("network.proxy.type", 1);
firefoxProfile.setPreference("network.proxy.http", "proxyserver");
firefoxProfile.setPreference("network.proxy.http_port", "80");
firefoxProfile.setPreference("extensions.firebug.currentVersion", "1.9.0");
String urlStrProxy = "http://www.example.com/",
proxy = "proxyserver",
port = "80",
username = "jack",
password = "XXXXXXX";
Authenticator.setDefault(new SimpleAuthenticator(username,password));
Properties systemProperties = System.getProperties();
systemProperties.setProperty("http.proxyHost",proxy);
systemProperties.setProperty("http.proxyPort","80");
WebDriver driverMainPage = new FirefoxDriver(firefoxProfile);
}
public class SimpleAuthenticator extends Authenticator
{
private String username, password;
public SimpleAuthenticator(String username,String password)
{
this.username = username;
this.password = password;
}
protected PasswordAuthentication getPasswordAuthentication()
{
return new PasswordAuthentication(username,password.toCharArray());
}
}
还尝试使用附加语句包含代理设置和身份验证详细信息,以通过代理服务器而无需
当Firefox访问www.abc.com而未成功时,必须通过弹出屏幕手动输入它们:
还添加了“-Dhttp.proxyHost=proxyserver-Dhttp.proxyPort=80-Dhttp.proxyUser=jack-Dhttp.proxyPassword=XXXXXXX”作为JVM选项
我在WindowsXP&7上运行Java7、Selenium2.25.0和NetBeans7.2
所有的搜索都没有直接回答这个问题
任何协助都将不胜感激
提前感谢,
杰克我想端口号应该是一个整数
firefoxProfile.setPreference(“network.proxy.http_port”,80)代码>
对于处理询问用户名和密码的弹出窗口,您可以根据提供的代码使用autoit,selenium ide代替firebug提供。看
File fireBugFile = new File("C:/selenium-ide-1.9.0.xpi");
FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.addExtension(fireBugFile);
所以这可能就是为什么fire bug没有得到。。用正确的版本w.r.t firefox提供Firebug的正确位置
对于身份验证,早在以前,我就在下面使用了一个,没有考虑firefox配置文件
driver.get("http://UserName:Password@Example.com");
还手动创建了firefox配置文件,并对该配置文件进行了身份验证。我在执行中调用了这个配置文件,这种方式在firefox中也非常有效
谢谢谢谢Abhi_Mishra的回复。在SeleniumWebDriver中使用firefoxprofile启动Firefox时无法加载Firebug的问题如何?谢谢,杰克