0

I have the below code for selenium

    public static void main(String[] args) {

    File file = new File("C:\\path\\IEDriverServer.exe");

    System.setProperty("webdriver.ie.driver", file.getAbsolutePath());

    WebDriver driver = new InternetExplorerDriver();

    driver.get("http://hedtq01vr.bcbsma.com:8080/tm/index.jsp?default");

    driver.quit();

}

When i try to run it fails with the below error:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/conn/SchemePortResolver

Below are the jars on the build path:

  • Selenium-java-2.42.2.jar
  • selenium-server-standalone-2.33.0.jar

and IEDriverServer.exe on the C:\path folder

Why am i getting this error..The page here doesn't talk anything about the required libraries.

Any suggestions?

EDIT:

After adding the libraries from the selenium folder, I am getting the below error:

Exception in thread "main" java.lang.NoSuchFieldError: INSTANCE

Here is the complete error link

1 Answer 1

2

The Selenium download comes as a ZIP file (selenium-java-2.42.2.zip), which contains not only Selenium-java-2.42.2.jar, but also a sub-directory named 'libs', and which contains a whole raft of JAR libraries that the Selenium jar presumably relies on. Among others the libs folder contains httpclient-4.3.2.jar, which is the Apache HTTP component containing the class your current setup cannot find. Add all the jars in the libs directory on your build path (and then on your classpath at runtime), and you should be sorted.

Sign up to request clarification or add additional context in comments.

4 Comments

Hi, Thanks for your reply..When i add the libraries given in the lib folder i am getting the below error:
OK, getting into guesswork now, but I noticed you have "selenium-server-standalone-2.33.0.jar" on your path, which, if used (and I'm not sure of that), may cause version incompatibilities. Why not make use of the matching version 2.42.2?
Having had a closer look, the version incompatibility theory is looking more likely: the class that is failing in your exception stack is contained in the server jar file, and as it's not the same version as the java jar, they could clash. BTW, are you sure you need the server jar on your path? Typically you write code for the client or for the server, but not both at once. Sharing client and server libraries on the same project can lead to such issues.
And to add to the point, the selenium setup instruction page indicates that you should "Add the selenium-java-<version-number>.jar files to your project as references", and does not mention the server jar.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.