2016-10-01 11 views
0

MavenでFirefoxDriverを使って簡単な自動テストを作成する必要があります。MavenでFirefoxでSelenium WebDriverテストケースを実行するには?

のpom.xmlからの抜粋:

<dependency> 
    <groupId>org.seleniumhq.selenium</groupId> 
    <artifactId>selenium-java</artifactId> 
    <version>2.53.1</version> 
</dependency> 

テスト・ケース:

@BeforeTest 
public void StartBrowser_NavURL() { 
    capability = DesiredCapabilities.firefox(); 
    capability.setCapability("platform", Platform.ANY); 
    capability.setCapability("binary", "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe"); 


    driver = new FirefoxDriver(capability); 
    driver.manage().window().maximize(); 
} 

@AfterTest 
public void CloseBrowser() { 
    driver.quit(); 
} 

@Test 
public void testToCompareDoubles() { 
    driver.get("http://www.google.com"); 
} 

とコマンドの実行テストを実行した後、私は次の例外を受け取り

mvn -test 

org.openqa.selenium.WebDriverException:ポート7055のバイナリFirefoxBinary(C:\ Program Files(x86)\ Mozilla Firefox \ firefox.exe)に接続できませんでした。プロセス出力は次のようになります。LightweightThemeManagerのシャットダウンブロッカを起動します。

Mozilla Firefox version: 49.0.1(Selenium Webdriverと互換性があります)。 "hosts"ファイルは空です。 Windowsのファイアウォールが無効になって

ご意見はありますか?問題を解決するにはどうすればよいですか?

答えて

1

Selenium2Mozilla Firefox version: 49.0.1の間に互換性の問題があるようです。

実際にはMozilla has launched executable geckodriver to support latest firefox >= v47はセレンで実行可能な他のドライバと同じです。

You need to download latest geckodriver executable firstは、抽出物は、任意の場所でお使いのシステムにzipファイルをダウンロードし、変数webdriver.gecko.driverで適切にSystemに実行可能ファイル自体でこの実行ファイルのパスを設定します。以下のように

Now run selenium script to launch Mozilla Firefox using marionette: -

System.setProperty("webdriver.gecko.driver", "path/to/geckodriver.exe"); 

//Now you can Initialize marionette driver to launch firefox 
DesiredCapabilities capabilities = DesiredCapabilities.firefox(); 
capabilities.setCapability("marionette", true); 

WebDriver driver = new MarionetteDriver(capabilities); //for selenium 3 use new FirefoxDriver(capabilities); 

: - Mozilla Firefoxは、お使いのシステムにデフォルトの場所にインストールした場合は、必要はセレンスクリプトに明示的にバイナリのパスを提供しないために、セレン自体はデフォルトの場所からそれを見つけるだろう。

関連する問題