2011-05-16 1 views
2

ここでは多大な努力をしていません。NoClassDefFoundError:Srienium for FirefoxDriverのorg/apache/http/HttpEntity

私はちょうど、Googleのページを開いて、編集ボックス

に検索文字列を入力するには、セレンのウェブサイトで与えられた例を実行しようとしています

しかし、私は次のエラーを取得:

*>例外ではスレッド「メイン」

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)*

私はこのClientProtocolException クラスであり、これを見つけるために何見当がつかない。

お一人お手伝いできますか?

コードは

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(); 

    } 
} 

よろしく、
ヴィカス

答えて

3

返信いただきありがとうございます。

私がやった間違いを見つけました。

私はIDEとしてEclipseを使用しています。外部参照JARファイルのリストで は、私が「セレンのjava-2.0b3.jar」を含めた

実は私は「セレン・サーバースタンドアロン・2.0b3.jar」

セレンのウェブサイトを含める必要がありました実際にサーバー用にダウンロードするjarファイルはありません!これはすべての混乱を作り出しました。

右のjarファイルを使用すると、「NoClassDefFoundError」はなくなります。

よろしくお願いいたします。 Vikas

0

をするSystem.setPropertyの呼び出しで(末尾の "firefox.exeを" との)Firefoxのアプリケーションへの完全なパスを与えるようにしてくださいです。 クラスパスも確認してください(Why am I getting a NoClassDefFoundError in Java?を参照)。

FirefoxまたはIEドライバを使用していますか?あなたはそれをコメントアウトしましたが、エラーはあなたのコードの別の状態から来ているようです。私は "ライン16"はあなたのドライバをインスタンス化する行だと思います、それは本当ですか?

関連する問題