繁体   English   中英

使用Selenium的线程“main”java.lang.IllegalStateException中的异常

[英]Exception in thread “main” java.lang.IllegalStateException for using Selenium

我使用Selenium来填写Web表单。我将库client-combined 3.0.0 beta 3到文档中。我的firefox版本应该是最新的。 然而,它出错了。如何解决? 或者使用webdriver作为Chrome更好?

 import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class Selenium {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {



WebDriver driver=new FirefoxDriver();

driver.get("https://mail.google.com");
driver.findElement(By.id("Email")).sendKeys("yourEmailId");
driver.findElement(By.id("Passwd")).sendKeys("yourPassword");
driver.findElement(By.id("signIn")).click();

}

}

线程“main”中的异常java.lang.IllegalStateException:驱动程序可执行文件的路径必须由webdriver.gecko.driver系统属性设置; 有关更多信息,请参阅https://github.com/mozilla/geckodriver 最新版本可以从https://github.com/mozilla/geckodriver/releases下载

对于使用Firefox的Selenium 3.x,请使用

System.setProperty("webdriver.gecko.driver", "path.to.geckodriver.exe");  
WebDriver driver = new FirefoxDriver();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM