我在eclipse中试过这段代码:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class auto {
public static void main(String[] args) {
System.setProperty("webdriver.gecko.driver", "/root/Desktop/jarselenium/geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.get("https://www.easybooking.lk/login");
//driver.manage().timeouts().implicitlyWait(25, TimeUnit.SECONDS);
}
}
执行时我遇到了这个错误:
Exception in thread "main" java.lang.IllegalStateException: The driver executable does not exist: /root/Desktop/jarselenium/geckodriver.exe
如何在ubuntu中设置geckodriver位置?
答案 0 :(得分:1)
当您使用基于Linux的系统同时指定 GeckoDriver 的绝对路径时,您必须修剪扩展部分,即.exe
部分,如下所示:< / p>
System.setProperty("webdriver.gecko.driver", "/root/Desktop/jarselenium/geckodriver");
当您仍然看到错误时,请确保:
@Test
。