-3

I have tried to download the new chrome driver and added it to my drivers folder, its still throwing the same error.

 import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.chrome.ChromeDriver;

    public class gmail {

    public static void main(String[] args) {


        WebDriver driver = new ChromeDriver();
        driver.get("https://mail.google.com");
        driver.findElement(By.id("Email")).sendKeys("********");
        driver.findElement(By.id("next")).click();
        driver.findElement(By.id("Passwd")).sendKeys("********");
        driver.findElement(By.id("signIn")).click();    
     }

    }

Error displayed:

    Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html at com.google.common.base.Preconditions.checkState(Preconditions.java:197)
Varun. K
  • 1
  • 2
  • `The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html` – sidgate Nov 02 '16 at 23:39

1 Answers1

0
System.setProperty("webdriver.chrome.driver", "location/of/chromedriver/in/system");
WebDriver chromeDriver = new ChromeDriver();
HARDI
  • 394
  • 5
  • 12
  • tried to use this but did not work, tried this later: System.setProperty("webdriver.chrome.driver", gmail.class.getClassLoader().getResource("drivers/chromedriver").getPath()); and it worked. – Varun. K Nov 10 '16 at 00:02