1

背景/セットアップ:
JUnit にはたくさんのテスト クラスがあります。すべてMavenとEclipseの両方で構成されています。各テスト クラスは RemoteWebDriver インスタンスをインスタンス化し、テスト クラスの実行が終了した後、tearDown メソッドでそれを終了します。

「mvn clean install」を実行してすべてのテストを実行しようとすると、一部のテストは正常に実行されますが、残りのテストは次の例外 (スタックトレース) のために失敗します。

Tests in error: 
  com.tagged.qa.selenium.tests.gifts.GiftsPageTest: Error communicating with the remote browser. It may have died.(..)
  com.tagged.qa.selenium.tests.tags.TagsPageTest: Error communicating with the remote browser. It may have died.(..)
  addFriendsTest(com.tagged.qa.selenium.tests.friends.FriendsTest): Error communicating with the remote browser. It may have died.(..)
  deleteFriendsTest(com.tagged.qa.selenium.tests.friends.FriendsTest): Error communicating with the remote browser. It may have died.(..)
  com.tagged.qa.selenium.tests.statusupdates.StatusUpdatesTest: Error communicating with the remote browser. It may have died.(..)
  com.tagged.qa.selenium.tests.comments.CommentsTest: Error communicating with the remote browser. It may have died.(..)
  com.tagged.qa.selenium.tests.search.SearchPageTest: Error communicating with the remote browser. It may have died.(..)
  com.tagged.qa.selenium.tests.homepage.HomePageTest: Error communicating with the remote browser. It may have died.(..)
  com.tagged.qa.selenium.tests.wink.WinkPageTest: Error communicating with the remote browser. It may have died.(..)
  com.tagged.qa.selenium.tests.profile.ProfilePageTest: Error communicating with the remote browser. It may have died.(..)
  com.tagged.qa.selenium.tests.footerpagestests.TermsOfServiceTest: Error communicating with the remote browser. It may have died.(..)

Tests run: 18, Failures: 0, Errors: 11, Skipped: 0

失敗した個々のテストについて target/surefire-reports/ のログを確認すると、次のようになります。

org.openqa.selenium.remote.UnreachableBrowserException: Error communicating with the remote browser. It may have died.
Caused by: org.openqa.selenium.WebDriverException: Session ID may not be null.

テストの実行中に、ブラウザー (私の場合は firefox) が開こうとしているのに、すぐに終了することに気付きました。Selenium サーバーは、セッション ID がないことをログに記録します。数回試行し、試行を終了します。その後、パイプライン内の他のすべてのテストが同じ理由で失敗します。

困惑しているのは、これらのテストを個別に実行しようとすると、この問題は発生しませんが、maven を使用してそれらすべてを一緒に実行しようとすると、これが一貫して発生するという事実です。助けてください?

4

3 に答える 3

0

よくわかりませんが、通常、一連のテストを実行すると失敗し、単一のテストを実行すると成功する場合、通常、原因は次のいずれかです。

1) スレッドの問題。これらのテストはマルチスレッドですか? その場合、何らかのリソース競合が発生している可能性があります。

2) ティアダウンの問題。新しいブラウザがきれいに起動できないなど、ブラウザを悪い状態のままにしているティアダウンで何かが起こっていますか?

Selenium テストの実行に Maven と Eclipse は使用していません。

于 2012-04-10T01:22:40.077 に答える
0

これが役立つかどうかはわかりませんが、3.xを超えるFirefoxのバージョンではmavenを介してセレンを動作させることができませんでした(3.18を使用したメモリから)。それ以降のバージョンを使用しているときに症状が発生しました。

私はすべてを試しましたが、敗北を認め、単純に古いバージョンをインストールして使用しました。

少なくともセレン テストは機能し、実際の作業に取り掛かりました。

于 2012-04-07T01:10:50.277 に答える
0

私のこのコードでも同じ問題がありました。

        WebDriver augmentedDriver;
        if(BrowserConfig.getHubURL().equalsIgnoreCase("none"))
            augmentedDriver = getDriver();
        else augmentedDriver = new Augmenter().augment(getDriver());

        LOGGER.info("Just before capture: ");
        LOGGER.info(augmentedDriver.toString());
        byte[] screenshot = ((TakesScreenshot) augmentedDriver).getScreenshotAs(OutputType.BYTES);

getscreenshot 呼び出しの前に、o フローで driver.quit() が呼び出されていることがわかりました。このb

于 2014-04-23T10:44:36.093 に答える