当我使用默认配置文件启动时没有问题。但是当我从自定义配置文件开始时,Firefox 启动但保持“阻止”状态。该进程仍然处于活动状态,消耗 31MB RAM,但从未启动。仅当我杀死该进程时才启动,然后启动并与硒一起正常工作。
我使用 Windows 7、Firefox 25.0.1 和 selenium-server-standalone-2.38.0.jar ¿也许版本兼容性有问题?
这是打开配置文件的代码:
FirefoxProfile profile = new FirefoxProfile(new File("C:/Users/UserTest/AppData/Roaming/Mozilla/Firefox/Profiles/tydtn9km.testprofile"));
WebDriver driver = new FirefoxDriver(profile);
编辑:
这是我的实际代码
package org.openqa.selenium.example;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.firefox.internal.ProfilesIni;
public class Main {
public static void main(String[] args) {
ProfilesIni profile = new ProfilesIni();
FirefoxProfile ffprofile = profile.getProfile("Other");
WebDriver driver = new FirefoxDriver(ffprofile);
driver.get("http://google.com");
}
}
编辑2:已解决出现此问题的原因是我的 Firefox 配置文件位于另一个分区,而 Firefox 位于另一个分区。
我一直这样使用它:
首先,创建一个 Firefox 配置文件并以您知道的方式命名。例如。SELENIUM
然后初始化您的个人资料:
ProfilesIni profile = new ProfilesIni();
FirefoxProfile ffprofile = profile.getProfile("SELENIUM");
WebDriver driver = new FirefoxDriver(ffprofile);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)