playのseleniumテストでqunitの実行結果を判定する

というわけで、qunitの実行結果をseleniumで判定することにした。
(play! には qunit module があったが、それは試していない。)

selenium ide の play! plugin(Selenium IDE plugin for the Play! framework)を導入してqunit用のhtmlを開いてキャプチャした。

今回は、タイトルが「✔ QUnit Test Suite」であればテスト成功とした。

「open」->「assertTitle」の順で実行すると、selenium ideでは成功するが、
selenium test runnerから実行すると、タイトルが変わる前にassertTitleが実行されるため失敗する。
なので、html内の最下部の要素「qunit-fixture」を「waitForElementPresent」に指定した。

「Application.test.html」に指定した内容は以下のとおり。

#{selenium 'qunit'}
    clearSession()
    open('/public/javascripts/test/test.html')
    waitForElementPresent('id=qunit-fixture','test markup')
    assertTitle('✔ QUnit Test Suite')
#{/selenium}

成功時

失敗時