2016-09-12 26 views
0

のWindows 10に入力取得されていませんビットセレンwebdriverを、3- URLをFirefoxブラウザ

package newpackage; 

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

    public class MyClass { 
    public static void main(String[] args) { 
    // declaration and instantiation of objects/variables 
      System.setProperty "webdriver.firefox.marionette","D:\\Selenium\\geckodriver.exe"); 
     //System.setProperty("webdriver.gecko.driver","D:\\Selenium\\geckodriver.exe"); 


     WebDriver driver = new FirefoxDriver(); 


    String baseUrl = "http://newtours.demoaut.com"; 
    String expectedTitle = "Welcome: Mercury Tours"; 
    String actualTitle = ""; 

    // launch Firefox and direct it to the Base URL 
    driver.get(baseUrl); 

    // get the actual value of the title 
    actualTitle = driver.getTitle(); 

    /* 
    * compare the actual title of the page witht the expected one and print 
    * the result as "Passed" or "Failed" 
    */ 
    if (actualTitle.contentEquals(expectedTitle)){ 
     System.out.println("Test Passed!"); 
    } else { 
     System.out.println("Test Failed"); 
    } 

    //close Firefox 
    driver.close(); 

    // exit the program explicitly 
    System.exit(0); 
} 


} 

エラー:

org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output: les":[],"targetApplications":[{"id":"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}","minVersion":"1.5","maxVersion":"9.9"}],"targetPlatforms":[],"multiprocessCompatible":false,"signedState":0,"seen":true}

+0

あなたのセレンとFirefoxのバージョンはお互いに互換性がありません。古いバージョンのfirefoxに切り替えるか、セレン版を安定版(v2.52.0)にダウングレードしてみてください – metar

+0

なぜこの行にコメントしていますか?System.setProperty( "webdriver.gecko.driver"、 "D:\\ Selenium \ \ geckodriver.exe ");'? –

+0

geckodriverを使ってFirefoxを起動するには、[このリンクにある](http://stackoverflow.com/questions/38676719/fail-to-launch-mozilla-with-selenium/38676858#38676858)をご覧ください。 –

答えて

0

この種の問題は、セレン3.0ベータ版で発生しています。

DesiredCapabilities capabilities = DesiredCapabilities.firefox(); 
capabilities.setCapability("marionette", true); 
WebDriver driver = new FirefoxDriver(capabilities); 

がgeckodriverのV 0.10.0で試してみました:次のように

あなたはセレンスタンドアロンの瓶を使用して使用している場合は、あなたは能力としてマリオネットを渡すとFirefoxDriverを初期化する必要があります。

String driverPath = "<path to gecko driver executable>"; 
public WebDriver driver; 
public void launchBrowser() { 
     System.out.println("launching firefox browser"); 
     System.setProperty("webdriver.gecko.driver", driverPath+"geckodriver.exe"); 
     driver = new FirefoxDriver(); 
    } 
関連する問題