I am trying to run the below code but java.lang.Illegalstate Exception is coming

0 votes
package org.selenium.sample;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class demo {

 public static void main(String[] args) {
  // TODO Auto-generated method stub
  

  System.setProperty("Webdriver.gecko.driver","C:\\Users\\abby\\Desktop\\geckodriver.exe");
  WebDriver x=new FirefoxDriver();

  x.get("http://google.com");
Jun 21, 2019 in Selenium by anonymous
261 views

2 answers to this question.

0 votes
Best answer

You are facing this error because while initializing firefox driver, you have used wrong keyword for setting Property i.e. instead of using:

System.setProperty("Webdriver.gecko.driver","C:\\Users\\abby\\Desktop\\geckodriver.exe");

Use: 

System.setProperty("webdriver.gecko.driver","C:\\Users\\abby\\Desktop\\geckodriver.exe");

webdriver.gecko.driver is the correct keyword for firefox driver. Now java is case-sensitive, so using Webdriver.gecko.driver, it will throw an error.

Hope this would help.

answered Jun 21, 2019 by Abha
• 27,930 points
0 votes
Thank you so much for answering.I have been struggling from past 3 days.
answered Jun 21, 2019 by anonymous
Your most welcome. Please feel free to ask any other questions you have.

Related Questions In Selenium

0 votes
0 answers
0 votes
0 answers
0 votes
0 answers

I am getting no such alert exception in selenium when i tried to run the script

I am getting error after executing the ...READ MORE

Feb 3 in Selenium by puneeth
• 120 points
800 views
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,520 points
3,785 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31 in Selenium by Sri
• 2,970 points
4,767 views
0 votes
2 answers

What is the role of TestNG & JUnit frameworks in Selenium?

TestNG and JUnit are test frameworks . it ...READ MORE

answered Sep 4 in Selenium by Sri
• 2,970 points
887 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,890 points
2,742 views