我正在使用 Selenium3 ,因为我们知道对FireFox进行了修改(它曾经是一个简单的调用),现在我们必须将它设置在指向geckodriver的属性中。
我正在使用 Chrome驱动程序,但收到错误:
The path to the driver executable must be set by the webdriver.gecko.driver system property.
这是m代码:
import org.openqa.selenium.chrome.*;
import org.openqa.selenium.WebDriver;
//import org.openqa.selenium.By;
import org.openqa.selenium.firefox.*;
public class DriverTest {
//@Test
public static void main(String [] args) {
System.setProperty("webdriver.gecko.driver","C:\\Users\\right\\pathHere\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
//Navigate to URL
driver.get("http://www.google.com");
driver.manage().window().maximize();
}
}
答案 0 :(得分:0)
尝试使用此路径:
System.setProperty("webdriver.chrome.driver","C:\\Users\\right\\pathHere\\chromedriver.exe");
答案 1 :(得分:0)
geckodriver 驱动程序适用于 FireFox 浏览器。因此,您应该在PC中安装 FireFox 。然后下载geckodriver并将其保留到C:\Users\right\pathHere\
现在使用 setProperty()方法设置 geckodriver ,如下所示:
System.setProperty("webdriver.gecko.driver","C:\\Users\\right\\pathHere\\geckodriver.exe");