Hello Everyone Welcome back to Selenium Webdriver tutorial series. Today in this article we are going to discuss one exception which everyone has faced while working with other browsers.
By default, Selenium works with Firefox without any driver but while working with other browsers like Chrome, IE, Opera and so on we need to use third party drivers and specify the path of them.
You can download all third party driver from Selenium official website
java.lang.illegalstateexception in Selenium Webdriver
The root cause of java.lang.illegalstateexception is we have not specified the path of the driver with the system property.
Until you do not specify the driver details Selenium Webdriver will throw java.lang.illegalstateexception.
I have faced a couple of exceptions while working with Selenium Webdriver and finally came across the solution for all.
Check below articles which will help you to understand which exceptions can come and how to handle them and it is one of the most important interview question as well.
Type of Exceptions in Selenium Webdriver?
Handle Stale Element References Exception
F.QueryInterface is not a function
For java.lang.illegalstateexception we have to use System class and method called setProperty which will accept key and value pair.
For Chrome what changes we have to make
System.setProperty("webdriver.chrome.driver","path of the chromedriver.exe");
WebDriver driver=new ChromeDriver();
For IE Browser below changes has to be done
System.setProperty("webdriver.ie.driver","path of the chromedriver.exe");
WebDriver driver=new InternetExplorerDriver();
I do not have enough content for this because this exception is just because of small mistake.
If you would like to know how to start with IE and Chrome browser then below article will help you.
Execute Selenium Script in Chrome Browser
Execute Selenium Script in IE Browser.
Please share your thoughts or view in the comment section.
For More updates Learn Automation page
For any query join Selenium group- Selenium Group
kranthi says
what about edge driver? Any one working on Edge driver please revert on how to solve this exception.
Mukesh Otwani says
Hi Kranthi,
You need to verify, whether the driver path is correct and logged in user has full privileges on the folder where driver has been placed
Gaurav Khurana says
Good to see that you have even shared a post on a small problem which even indicates the error message clearly.
Good thing is we came to know one more exception explicitly which can be used in interview Questions
Preetish Kumar Mahato says
finally i solve the error , autully i was not passing the object of FileInputStream into XSSFworkbook .
Mukesh Otwani says
Cheers
karishma says
Hi Mukesh,
Getting “java.lang.IllegalStateException” though I provided key and path value for opera but for chrome its working fine.
Mukesh Otwani says
Hi Karishma,
I have not tried with Opera. If you have find the solution please share with us so it will help others as well.