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

  WebDriver x=new FirefoxDriver();

Jun 21 in Selenium by anonymous

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:




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 by Abha
• 27,180 points
0 votes
Thank you so much for answering.I have been struggling from past 3 days.
answered Jun 21 by anonymous
Your most welcome. Please feel free to ask any other questions you have.

Related Questions In Selenium

0 votes
1 answer

I tried the below code but multiple instances are being created

Remove the driver initialization from @BeforeClass/ returnDriver() ...READ MORE

answered Mar 29, 2018 in Selenium by DragonLord999
• 8,380 points
0 votes
1 answer

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,110 points
0 votes
1 answer
0 votes
1 answer

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

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

answered Apr 18, 2018 in Selenium by king_kenny
• 3,650 points
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,130 points