1

バックグラウンド

私は、Selenium 1.0 (RC) で開発した Selenium テスト スイートを自動化し、これをビルド マシンの継続的統合システム (この場合はTeamCity ) に接続することに取り組んでいます。ビルド マシンでスイートを手動で実行できるという事実にすぐに遭遇しましたが、TeamCity で実行すると失敗しました。

完全を期すために、成功した場合の Selenium サーバー ログは次のようになります。

18:26:09.025 INFO [12] org.openqa.selenium.server.SeleniumDriverResourceHandler - Command request: getNewBrowserSession[*iexplore, http://dev2mx:8080/, ] on session null
18:26:09.041 INFO [12] org.openqa.selenium.server.BrowserSessionFactory - creating new remote session
18:26:09.072 DEBUG [12] org.openqa.selenium.server.browserlaunchers.BrowserLauncherFactory - Requested browser string '*iexplore' matches *iexplore
18:26:09.072 INFO [12] org.openqa.selenium.server.BrowserSessionFactory - Allocated session 1c8363f1edbc40b9b251e3bf4bd3d74f for http://portaldev2:80/, launching...
18:26:09.103 DEBUG [12] org.openqa.selenium.server.browserlaunchers.ResourceExtractor - Extracting /core to C:\DOCUME~1\devadmin\LOCALS~1\Temp\5\customProfileDir1c8363f1edbc40b9b251e3bf4bd3d74f\core
18:26:09.244 INFO [12] org.openqa.selenium.server.browserlaunchers.HTABrowserLauncher - Launching Embedded Internet Explorer...
18:26:09.260 DEBUG [12] org.openqa.selenium.browserlaunchers.locators.BrowserLocator - Discovering Internet Explorer...
18:26:09.260 DEBUG [12] org.openqa.selenium.browserlaunchers.locators.BrowserLocator - Checking whether Internet Explorer launcher at :'C:\Program Files\Internet Explorer\iexplore.exe' is valid...
18:26:09.260 DEBUG [12] org.openqa.selenium.browserlaunchers.locators.BrowserLocator - Discovered valid Internet Explorer launcher  : 'C:\Program Files\Internet Explorer\iexplore.exe'
18:26:09.275 INFO [12] org.openqa.selenium.server.browserlaunchers.HTABrowserLauncher - Launching Internet Explorer HTA...
18:26:09.291 DEBUG [12] org.openqa.selenium.server.FrameGroupCommandQueueSet - waiting for window 'null' local frame 'null' for 1800 more secs
18:26:09.291 DEBUG [12] org.openqa.selenium.server.FrameGroupCommandQueueSet - waiting for condition for 1000 more ms
18:26:10.307 DEBUG [12] org.openqa.selenium.server.FrameGroupCommandQueueSet - got condition? : false
18:26:10.307 DEBUG [12] org.openqa.selenium.server.FrameGroupCommandQueueSet - waiting for window 'null' local frame 'null' for 1799 more secs
18:26:10.307 DEBUG [12] org.openqa.selenium.server.FrameGroupCommandQueueSet - waiting for condition for 1000 more ms
18:26:10.994 DEBUG [13] org.openqa.jetty.http.HttpConnection - new HttpConnection: Socket[addr=/127.0.0.1,port=3255,localport=4444]
18:26:11.010 DEBUG [13] org.openqa.jetty.http.HttpConnection - REQUEST from SocketListener0@0.0.0.0:4444:

最後の 2 行に到達しないことで、ログに障害モードが現れました。すぐ上の待機列は、待って待って待っていました。

12:19:16.191 DEBUG [12] org.openqa.selenium.server.FrameGroupCommandQueueSet - waiting for window 'null' local frame 'null' for 1800 more secs
12:19:16.191 DEBUG [12] org.openqa.selenium.server.FrameGroupCommandQueueSet - waiting for condition for 1000 more ms
12:19:17.191 DEBUG [12] org.openqa.selenium.server.FrameGroupCommandQueueSet - got condition? : false
12:19:17.191 DEBUG [12] org.openqa.selenium.server.FrameGroupCommandQueueSet - waiting for window 'null' local frame 'null' for 1799 more secs
12:19:17.191 DEBUG [12] org.openqa.selenium.server.FrameGroupCommandQueueSet - waiting for condition for 1000 more ms
12:19:18.207 DEBUG [12] org.openqa.selenium.server.FrameGroupCommandQueueSet - got condition? : false
12:19:18.238 DEBUG [12] org.openqa.selenium.server.FrameGroupCommandQueueSet - waiting for window 'null' local frame 'null' for 1798 more secs
12:19:18.238 DEBUG [12] org.openqa.selenium.server.FrameGroupCommandQueueSet - waiting for condition for 1000 more ms
12:19:19.254 DEBUG [12] org.openqa.selenium.server.FrameGroupCommandQueueSet - got condition? : false
12:19:19.254 DEBUG [12] org.openqa.selenium.server.FrameGroupCommandQueueSet - waiting for window 'null' local frame 'null' for 1797 more secs
12:19:19.254 DEBUG [12] org.openqa.selenium.server.FrameGroupCommandQueueSet - waiting for condition for 1000 more ms
12:19:20.269 DEBUG [12] org.openqa.selenium.server.FrameGroupCommandQueueSet - got condition? : false

Selenium RC から Selenium 2.0b2 にアップグレードし、サーバー jar とライブラリ参照を交換することから始めて、問題を調べるためにさまざまな角度から考えました。同じ結果です。

次に、WebDriver と Selenium 2.0 に置き換えてさらに切り替えることを考えました。

selenium = new DefaultSelenium("localhost", port, browserType, pageToOpen);

selenium = new WebDriverBackedSelenium(driver, pageToOpen);

私がすぐに遭遇したのは、WebDriver がフレームに関してより厳密であるということです! 後続のオブジェクトがどのフレームにあると想定されているかをより厳密に指定するまで、私のテストは失敗しました.

並行して、Selenium とヘッドレス構成と継続的インテグレーションについて読み始めました。継続的インテグレーション サーバーは、ほぼ定義上、すべてをヘッドレスで実行する必要があるようですが、セレンにはディスプレイが必要です。対立。(実際のブラウザーに対してテストしたいので、HtmlUnitDriver を使用したくありません。2.0b2 の .NET 用の HtmlUnitDriver はまだ存在しないことは言うまでもありません!) Linux のソリューションとしてxvfbについて読みましたが、Windows Server を使用しています。 2003. 最も可能性の高い解決策は、他のマシンで実際のブラウザーを起動できる Selenium Grid を使用することです。残念ながら、Selenium 2 用の Grid はまだ存在しないため、当面は Selenium RC を使い続けることになります。理想的ではありませんが、私はそれで暮らすことができました。

質問

私はまだ Grid を見ていないので、おそらく単純な質問です: Grid (TeamCity でヘッドレスで実行されている) は、リモートマシンで実際のブラウザーを開くのに問題がありますか?

Selenium 2 (グリッドをサポートしていない) を継続的インテグレーションで接続する方法はありますか?

4

2 に答える 2

1

素朴な答えは次のとおりです。

Grid は、リモート マシンで実際のブラウザを開くことに問題はありません。

グリッドをサポートする Selenium 2 を使用できるはずです。Selenium 1 を使用するのと同じはずです。

nb「質問」を読んで答えるべきだった;-)

于 2011-03-23T06:57:32.523 に答える
1

次のような無限のエラーメッセージに関して、同様の問題に遭遇しました。

12:19:16.191 DEBUG [12] org.openqa.selenium.server.FrameGroupCommandQueueSet - waiting for window 'null' local frame 'null' for 1800 more secs
12:19:16.191 DEBUG [12] org.openqa.selenium.server.FrameGroupCommandQueueSet - waiting for condition for 1000 more ms

結局のところ、ビルド エージェントを Windows サービスとして実行すると、ブラウザーのプロセスが実行されますが、Selenium が対話できる実際のブラウザーは実行されません。サービスを停止し、ビルド エージェントのbinディレクトリに移動し、ビルド エージェントを手動で起動すると ( agent.bat start)、TeamCity によってビルドされたときに、選択したブラウザーに対して機能するセレン テストが表示されます。

それが役立つことを願っています!

于 2011-06-22T21:47:26.530 に答える