selenium 使用问题求大神帮助
我是初学者在myEclipse 下运行如下脚本老是报错请大神帮助看一下代码
package test;
import org.openqa.grid.selenium.*;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class test {
public static void main (String[] args)
{
System.setProperty("webdriver.firefox.bin","E:/Program Files (x86)/Mozilla Firefox/firefox.exe");
WebDriver driver = new FirefoxDriver();
driver.get("http://fuhzou,scity.cn");
String url = driver.getCurrentUrl();
System.out.print(url);
driver.close();
}
}
报错
Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.com/mozilla/geckodriver. The latest version can be downloaded from https://github.com/mozilla/geckodriver/releases
at com.google.common.base.Preconditions.checkState(Preconditions.java:199)
at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:109)
at org.openqa.selenium.firefox.GeckoDriverService.access$000(GeckoDriverService.java:37)
at org.openqa.selenium.firefox.GeckoDriverService$Builder.findDefaultExecutable(GeckoDriverService.java:95)
at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:296)
at org.openqa.selenium.firefox.FirefoxDriver.createCommandExecutor(FirefoxDriver.java:277)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:247)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:242)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:238)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:127)
at test.test.main(test.java:13)
报错信息不是写得挺明白的吗,下载链接都给你了,是缺少geckodriver或者是geckodriver放置的位置不对。(selenium3驱动火狐需要geckodriver)
Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.com/mozilla/geckodriver. The latest version can be downloaded from https://github.com/mozilla/geckodriver/releases
需要下载FireFox的驱动程序,这个自己百度下下载一个就可以。 清晨一缕阳光 发表于 2017-2-20 18:26
需要下载FireFox的驱动程序,这个自己百度下下载一个就可以。
您好您说的FireFox驱动 指的是WebDriver FirefoxDriver 还是FireFox的浏览器。如果是的话我都有装 若尘_51 发表于 2017-2-21 10:49
报错信息不是写得挺明白的吗,下载链接都给你了,是缺少geckodriver或者是geckodriver放置的位置不对。(se ...
谢谢了可以用了
页:
[1]