Java版本-1.8
Eclipse版本-2018-09(4.9.0)
硒-3.141
Firefox可扩展文件-v0.23.0
我的代码:
package testcases;
import org.openqa.selenium.firefox.FirefoxDriver;
public class TestBrowsers {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.setProperty("webdriver.gecko.driver", "C:\\Users\\adiwakar\\Documents\\Selenium Browser files");
FirefoxDriver driver = new FirefoxDriver();
driver.get("https://www.google.com/");
}
}
错误:
Exception in thread "main" java.lang.IllegalStateException: The driver executable is a directory: C:\Users\adiwakar\Documents\Selenium Browser files
at com.google.common.base.Preconditions.checkState(Preconditions.java:585)
at org.openqa.selenium.remote.service.DriverService.checkExecutable(DriverService.java:148)
at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:141)
at org.openqa.selenium.firefox.GeckoDriverService.access$100(GeckoDriverService.java:44)
at org.openqa.selenium.firefox.GeckoDriverService$Builder.findDefaultExecutable(GeckoDriverService.java:167)
at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:355)
at org.openqa.selenium.firefox.FirefoxDriver.toExecutor(FirefoxDriver.java:190)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:147)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:125)
at testcases.TestBrowsers.main(TestBrowsers.java:10)
答案 0 :(得分:1)
您似乎已将路径定义为驱动程序,应将驱动程序可执行文件路径定义为驱动程序,例如以下代码:
System.setProperty("webdriver.gecko.driver", "C:\\Users\\adiwakar\\Documents\\yourDriver.exe");