Sun, Nov 10, 2019
Read in 1 minutes
java.lang.IllegalStateException: The driver executable does not exist:
When you try to learn selenium with java to automate your testing, the most common problems are
Reason for the error:
Your system is not able to find the Chrome Driver executable.
Solution:
You can download the chrome driver executables from chromedriver/downloads
And, to solve the issue, you have to set the path(where you have copied the downloaded driver exe) to “webdriver.chrome.driver” key.
Note:
You have to set the driver’s property, after initializing driver object.
Example Program :
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class ChromeAutomation
{
public static void main(String[] args)
{
WebDriver driver = new ChromeDriver();
//initialize the driver object
System.setProperty("webdriver.chrome.driver",
"/Users/chrome/chromedriver.exe");
//set the system property webdriver.chrome.driver to the path
driver.get("https://www.google.com");
//mention the website url
driver.quit(); //to close the browser
}
}
Conclusion
In this Article, you explored the introduction program in selenium with java for automation testing and also you learned about the environment set up for chrome browser. If you are MAC user, you can click “Finder” and select the “GO” menu and go the folder /usr/local/bin and copy the ChromeDriver.exe.By doing this you don’t need to set the path.