Click here to Skip to main content
15,120,268 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have used the code

WebDriver driver=new ChromeDriver();


It throws the error

java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property;


It's because I didn't set the system property. But, my doubt is how does it know the exact property name which is webdriver.chrome.driver ?

What I have tried:

I need to know what happens when I do this:
WebDriver driver=new ChromeDriver();
Posted
Updated 7-Jun-21 4:58am
v2
Comments
Richard MacCutchan 28-May-21 10:59am
   
Most likely because the people who wrote the code for the ChtomeDriver knew what they were doing. If you want the full explanation then check the documentation.

So what happened when you Googled for "The path to the driver executable must be set by the webdriver.chrome.driver system property"?

Always Google for the error message and do a little research before posting a question.
   
Comments
15160877 31-May-21 0:55am
   
I did. I couldn't find any docs related to ChromeDriver(). My problem is not the error message. I just want to know the reason how ChromeDriver() is throwing exception with exact property name.
Dave Kreskowiak 31-May-21 10:11am
   
Oh really? I don't believe you. The FIRST result when Googling the exact error message you posted: https://stackoverflow.com/questions/44476647/getting-the-path-to-the-driver-executable-must-be-set-by-the-webdriver-chrome-d[^]
15160877 7-Jun-21 7:03am
   
My problem is not the error message!!! I solved the error. My question is, how does the ChromeDriver() knew which property to set. It throws the error like, "The path to the executables must be set by webdriver.chrome.driver." How does the ChromeDriver() know the exact property name to be set? That was my question.
Richard MacCutchan 7-Jun-21 10:29am
   
As already suggested, check the documentation: ChromeDriver - WebDriver for Chrome - Getting started[^]
15160877 16-Jun-21 3:20am
   
Yes, found it. Thank you
System Properties (The Java™ Tutorials)[^]
Wouldn't is make sense the ChromeDriver class can also query the System properties, with System.getProperty and an arbitrarily chosen property name?
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900