https://github.com/bonigarcia/webdrivermanager/

<dependency>
    <groupId>io.github.bonigarcia</groupId>
    <artifactId>webdrivermanager</artifactId>
    <version>4.2.2</version>
    <scope>test</scope>
</dependency>

  

引入该包之后,调用WebDriverManager.chromedriver().setup()即可

 

public class ChromeTest {

    private WebDriver driver;

    @BeforeClass
    public static void setupClass() {
        WebDriverManager.chromedriver().setup();
    }

    @Before
    public void setupTest() {
        driver = new ChromeDriver();
    }

    @After
    public void teardown() {
        if (driver != null) {
            driver.quit();
        }
    }

    @Test
    public void test() {
        // Your test code here
    }

}

  

相关文章:

  • 2021-05-22
  • 2021-05-04
  • 2021-09-11
  • 2021-09-10
  • 2021-12-04
  • 2021-12-10
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-14
  • 2021-10-27
  • 2021-07-22
  • 2022-01-02
  • 2022-01-30
  • 2021-09-18
相关资源
相似解决方案