简体   繁体   中英

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

I m using Selenium to fill in web forms .I added the library client-combined 3.0.0 beta 3 to the document .My firefox version should be most updated . However , it comes out error .How to fix ? Or using webdriver as Chrome better?

 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();

}

}

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

For Selenium 3.x with Firefox, use

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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