3 回答
TA贡献1848条经验 获得超2个赞
您可以使用FireFoxProfile类和FirefoxOptions类来设置配置文件。
FirefoxOptions options = new FirefoxOptions();
FirefoxProfile firefoxProfile = new FirefoxProfile(pathToProfile);
options.setProfile(firefoxProfile);
TA贡献1936条经验 获得超6个赞
乍一看,firefox.exe 的路径丢失了。有我的设置:
public class foo{
private static WebDriver driver;
@BeforeClass
public static void setUpClass() {
FirefoxOptions options = new FirefoxOptions();
ProfilesIni allProfiles = new ProfilesIni();
FirefoxProfile selenium_profile = allProfiles.getProfile("selenium_profile");
options.setProfile(selenium_profile);
options.setBinary("C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");
System.setProperty("webdriver.gecko.driver", "C:\\Users\\pburgr\\Desktop\\geckodriver-v0.20.0-win64\\geckodriver.exe");
driver = new FirefoxDriver(options);
driver.manage().window().maximize();}
// @Before, @After, @AfterClass and @Test
}
添加回答
举报