Getting Error in System setProperty of ChromeDriver

0 votes

I have written the correct code for setting the property of ChromeDriver and the path is also correct, still, I am getting error. 

My code:

WebDriver driver = new ChromeDriver();
  System.setProperty("webdriver.chrome.driver",
                     "D:\\List_of_Jar\\chromedriver.exe");    
       String Url = "https://www.google.com";driver.get(Url);

I am getting an error as " java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property;"

Apr 19, 2018 in Selenium by Damon Salvatore
• 5,980 points
• 12,083 views
I am Exactly facing that Same Problem ,Please help me out here..

2 answers to this question.

0 votes

You are launching the browser before setting its system.set property.This is only the error. 

The correct fromat for the code will be:

  System.setProperty("webdriver.chrome.driver","D:\\List_of_Jar\\chromedriver.exe");     
WebDriver driver = new ChromeDriver();  
String Url = "https://www.google.com";driver.get(Url);

 

answered Apr 19, 2018 by Meci Matt
• 9,460 points
0 votes
System.setProperty("webdriver.chrome.driver",
                   "D:\\List_of_Jar\\chromedriver.exe");

put it first and then

WebDriver driver = new ChromeDriver();
String Url = "https://www.google.com";driver.get(Url);

now it will work

answered Jan 8, 2019 by anonymous