2

I am not trying to do much here.

I am just trying to run an example given in Selenium website, to just open Google page and enter a search string in the edit box

But I get the following error:

*> Exception in thread "main"

java.lang.NoClassDefFoundError: org/apache/http/client/ClientProtocolException at org.openqa.selenium.ie.InternetExplorerDriver.setup(InternetExplorerDriver.java:92) at org.openqa.selenium.ie.InternetExplorerDriver.(InternetExplorerDriver.java:56) at com.testscripts.Selenium2Example.main(Selenium2Example.java:16)*

I have no idea what this ClientProtocolException Class is and where to find this.

Could any one of you please help ?

Code Is

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
//import org.openqa.selenium.ie.*;

public class Selenium2Example  {
    public static void main(String[] args) {
        // Create a new instance of the Firefox driver
        // Notice that the remainder of the code relies on the interface, 
        // not the implementation.
        System.setProperty("webdriver.firefox.bin", "C:\\Documents and Settings\\Vikas Kashyap\\Local Settings\\Application Data\\Mozilla Firefox\\firefox");

        WebDriver driver = new FirefoxDriver();

        //WebDriver driver = new InternetExplorerDriver();

        // And now use this to visit Google
        driver.get("http://www.google.com");

        // Find the text input element by its name
        WebElement element = driver.findElement(By.name("q"));

        // Enter something to search for
        element.sendKeys("Cheese!");

        // Now submit the form. WebDriver will find the form for us from the element
        element.submit();

        // Check the title of the page
        System.out.println("Page title is: " + driver.getTitle());


        //Close the browser
        driver.quit();

    }
}

Regards,
Vikas

2 Answers 2

3

Thanks for the reply.

I found out the mistake that I had done.

I am using Eclipse as my IDE. In the list of externally referenced JAR files, I had included "selenium-java-2.0b3.jar"

Actually I had to include "selenium-server-standalone-2.0b3.jar"

Selenium website doesnt really say which jar file to download for the server! This created all the confusion.

Using the right jar file, there's no more "NoClassDefFoundError" .

Regards Vikas

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

Comments

0

Try to give the complete path to your Firefox application (with "firefox.exe" at the end) in the System.setProperty call. Verify your classpath as well (see Why am I getting a NoClassDefFoundError in Java?).

Do you use the Firefox or the IE driver? You commented it out, but it looks like the error comes from another state of your code. I guess the "line 16" is the line where you instantiate your driver, is it true?

Comments

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.