相关疑难解决方法(0)

如何在 Selenium Webdriver 3 中为 Firefox 驱动程序设置默认配置文件?

我无法在 Selenium Webdriver 3 中为 Firefox 设置默认配置文件,因为FirefoxDriver类中没有这样的构造函数。

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.firefox.ProfilesIni;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

public class SeleniumStartTest {
    @Test
    public void seleniumFirefox() {
        System.setProperty("webdriver.gecko.driver", "C:\\Users\\FirefoxDriver\\geckodriver.exe");
        ProfilesIni profileIni = new ProfilesIni();
        FirefoxProfile profile = profileIni.getProfile("default");
        WebDriver driver = new FirefoxDriver(profile);
        driver.get("http://www.google.com");
    }
}
Run Code Online (Sandbox Code Playgroud)

Java 代码中的编译错误: Java 代码

Mavenpom.xml依赖项: Selenium 3.14.0

火狐版: 火狐版 62.0.2

java firefox selenium geckodriver firefox-profile

6
推荐指数
1
解决办法
9614
查看次数

标签 统计

firefox ×1

firefox-profile ×1

geckodriver ×1

java ×1

selenium ×1