我已经在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位置?
当您在指定 GeckoDriver 的绝对路径时使用 基于Linux的系统 时,必须修剪扩展部分,即part,如下所示: __.exe
.exe
System.setProperty("webdriver.gecko.driver", "/root/Desktop/jarselenium/geckodriver");
如您仍在看到错误,请确保:
@Test