-3

following is the code:

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

import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;

public class Browser {

public static void main(String args[]){

    WebDriver driver= new ChromeDriver();
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

    driver.get("https://q-apis-two.iot-build.qa.covapp.io/#/dashboard");
    driver.manage().window().maximize();

    driver.findElement(By.id("user")).sendKeys("Q-APIS-TWO_ADMIN");
    driver.findElement(By.id("password")).sendKeys("Covisint111");

    driver.manage().timeouts().implicitlyWait(60,TimeUnit.SECONDS);
    driver.findElement(By.className("btn btn-lg btn-primary btn-block")).click();


    driver.close();
}
}

It throws the following error: 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

I am new to selenium kindly guide me please

Radhika
  • 109
  • 5
  • 17

2 Answers2

1

First you need to install chromedriver. You can download desired driver from the list given in link below

https://sites.google.com/a/chromium.org/chromedriver/downloads

Then you need to set the location of chromedriver before your code as

System.setProperty("webdriver.chrome.driver", "/home/eclipse-workspace/chromedriver");

where home/eclipse-workspace/chromedriver is the path location

0

You missed the chromedriver path

System.setProperty("webdriver.chrome.driver", "E:\\sankalp\\my_Selenium\\chromedriver.exe");

//then your code

WebDriver driver= new ChromeDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

driver.get("https://q-apis-two.iot-build.qa.covapp.io/#/dashboard");
driver.manage().window().maximize();

driver.findElement(By.id("user")).sendKeys("Q-APIS-TWO_ADMIN");
driver.findElement(By.id("password")).sendKeys("Covisint111");

driver.manage().timeouts().implicitlyWait(60,TimeUnit.SECONDS);
driver.findElement(By.className("btn btn-lg btn-primary btn-block")).click();


driver.close();

Please change the path where you store the chromedriver.exe

iamsankalp89
  • 4,607
  • 2
  • 15
  • 36