enter image description here

I am trying to configure Selenium WebDriver with Eclipse IDE. While running my code I am getting java exception has occurred error. How to fix this?

import java.io.File;
import java.io.IOException;

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

public class Test {

    static WebDriver driver1=new ChromeDriver();
    String user="rutvisoni"; 
    String pass="12Abcd";

    public void setup() throws IOException

        //File inputFile = new ClassPathResource("E:\\Selenium Jar\\chromedriver.exe").getFile();
        System.setProperty("webdriver.chrome.driver","E:\\Selenium Jar\\chromedriver.exe");


    public static void main(String args[]) throws IOException
        Test t1=new Test();

  • Have you configured the environment variable path for JAVA in your computer? Nov 21, 2016 at 10:09
  • yes Configured the environment variable path for JAVA
    – Rutvi Soni
    Nov 21, 2016 at 10:12
  • Would you share your code so that people here can understand the problem and try to figure out a solution? Nov 21, 2016 at 10:13
  • Please check browser version.Is it compitable? Nov 21, 2016 at 10:26

1 Answer 1


You are initializing chrome in a wrong way. In your code you have maximized browser and called the URL, before even setting up the chrome profile. You can give a try to below code:

System.setProperty("webdriver.chrome.driver", "E:\\Selenium Jar\\chromedriver.exe");
            ChromeOptions options = new ChromeOptions();
            driver = new ChromeDriver();


And please remove the code line mentioned below from your code:

static WebDriver driver1=new ChromeDriver();

If you still face same exception, please share the exception details.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.