2016-10-18 7 views
0

スレッド "main"の例外java.lang.IllegalStateException:ドライバの実行可能ファイルへのパスは、webdriver.gecko.driverシステムプロパティで設定する必要があります。詳細については、https://github.com/mozilla/geckodriverを参照してください。最新バージョンはhttps://github.com/mozilla/geckodriver/releasesからダウンロードできます。Eclipseでパッケージを実行中にエラーが発生する

これは私のコードです。

package newpackage; 

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

public class MyClass { 

    public static void main(String[] args) { 
     //declaration and instatiation of objects/variables 

     WebDriver driver = new FirefoxDriver(); 
     String baseUrl = "http://newtours.demoaut.com"; 
     String expectedTitle = "Welcome: Mercury Tours"; 
     String actualTitle =""; 

     //launch firefox and direct it to the URL 

     driver.get(baseUrl); 

     //get the actual value of the title 

     actualTitle = driver.getTitle(); 



     if (actualTitle.contentEquals(expectedTitle)){ 
      System.out.println("Test Passed"); 

     }else { 
      System.out.println("Test failed"); 
     } 


     //close firefox 

     driver.close(); 

     //exit the program 

     System.exit(0); 

    } 

} 
+0

あなたの指示に従ったとき...? – nitind

+3

質問に適切なタグを追加することが重要です。回答できる問題を探しているほとんどの人は、よく知っている言語を検索するので、少なくともタグとして含める必要があります。 Stack Overflowの* markdown *の書式も読んで、読みやすくする必要があります。今回はあなたの質問を編集しました。あなた自身でそれをすることを学んでください。 – Borodin

+0

[Seleniumを使用してMozillaを起動できない](http://stackoverflow.com/questions/38676719/fail-to-launch-mozilla-with-selenium)の可能な複製 –

答えて

0

セレン3.0以上では、gecko.driverのパスを指定する必要があります。ドライバを初期化する前に以下の行をコードに追加してください。エラーは表示されません。

System.setProperty("webdriver.firefox.marionette","xxx\geckodriver.exe"); 
//xxx - path to geckodriver.exe file 
WebDriver driver = new FirefoxDriver(); 
関連する問題