1、遇见这个问题,先看看是否chromedriver没生效
2、找到代码对应目录,下载chrome对应版本的chromedriver替换进去
package com.sf.acsp.ebill.testcase;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
//import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class Test {
public static void main(String[] args)
{
WebDriver driver;
System.setProperty("webdriver.chrome.driver", "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chromedriver.exe");
//这里的驱动路径一定要写双斜杠,转义
driver = new ChromeDriver();
driver.get("https://www.baidu.com");
}
}
原文地址:https://www.cnblogs.com/lianlianqingning/p/9650787.html
时间: 2024-10-08 20:36:53