import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class Sanclass {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.getProperty("webdriver.chrome.driver", "C:\\Users\\SANIKA K\\Downloads\\chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.get("https://www.facebook.com/");
}
}
类型不匹配:无法从ChromeDriver转换为WebDriver
答案 0 :(得分:0)
似乎您无法像这样将WebDriver转换为ChromeDriver。尝试像这样启动驱动程序:
public static void main(String[] args) {
service = new ChromeDriverService.Builder()
.usingDriverExecutable(new File("path/to/my/chromedriver.exe"))
.usingAnyFreePort()
.build();
service.start();
}
参考: https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/chrome/ChromeDriver.html