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.
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
<span style="font-size: 14pt; font-family: arial, helvetica, sans-serif;">System.setProperty("webdriver.chrome.driver","path of the chromedriver.exe");
WebDriver driver=new ChromeDriver();</span>
For IE Browser below changes has to be done
<span style="font-size: 14pt; font-family: arial, helvetica, sans-serif;">System.setProperty("webdriver.ie.driver","path of the chromedriver.exe");
WebDriver driver=new InternetExplorerDriver();</span>
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.
Please share your thoughts or view in the comment section.
For More updates Learn Automation page
For any query join Selenium group- Selenium Group