3 回答

TA貢獻1848條經驗 獲得超2個贊
您可以使用FireFoxProfile類和FirefoxOptions類來設置配置文件。
FirefoxOptions options = new FirefoxOptions();
FirefoxProfile firefoxProfile = new FirefoxProfile(pathToProfile);
options.setProfile(firefoxProfile);

TA貢獻1936條經驗 獲得超7個贊
乍一看,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
}
添加回答
舉報