chromeDriver自动更新版本
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 } }