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
1,092 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
• 28,140 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 4, 2020 in Selenium by puneeth
• 120 points
3,219 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,500 points
13,793 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

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

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,198 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, 2020 in Selenium by Sri
• 3,190 points
2,960 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,910 points
7,280 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP