
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
ChromeDriver Executable Does Not Exist - IllegalStateException in Java Selenium
An IllegalStateException is thrown while working with Chrome browser if the chromedriver.exe file path is set incorrectly in the method System.setProperty. Once this executable file is downloaded, it has to be extracted. Then its path should be copied and added as a parameter to the System.setProperty method.
Syntax
System.setProperty("webdriver.chrome.driver", "C:\Users\ghs6kor\Desktop\DebomitaJava\chromedriver.exe")
Also, it must be remembered that, for Windows, we have to specify the .exe extension while including the path. But it is not required for Mac or Ubuntu. We should also ensure that the chromedriver.exe file that we are using is compatible with the local Chrome browser version.
Let us see an example for IllegalStateException.
Example
import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import java.util.concurrent.TimeUnit; public class PathChromeDriver{ public static void main(String[] args) { //path of chromedriver.exe set System.setProperty("webdriver.chrome.driver", "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe"); WebDriver driver = new ChromeDriver(); //implicit wait driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS); //launch URL driver.get("https://www.tutorialspoint.com/about/about_careers.htm"); System.out.println("Page title is: " + driver.getTitle()); driver.quit(); } }
Output
Advertisements