0

私は Selenium に取り組んでおり、現在、すべてのブラウザーで Linux を実行している 2 つの VM にハブが接続されています。

ブラウザを起動できました。ただし、2 つの VM がある場合でも、すべてのテストは 1 つの VM 上の 1 つのブラウザーで実行されます。Selenium は、VM で複数のブラウザーを起動しません。最大インスタンスを 5 に設定すると、gris コンソールに反映されます。Linux と Windows vm で実行する必要があるテストスイートがあり、同時に実行する必要があります。WebDriver を使用して、このようにグリッドを呼び出します。

 capabilities = new DesiredCapabilities();
           capabilities.setBrowserName("firefox");
           driver = new RemoteWebDriver(new URL("http://XXX.XXX.XXX.:4444/wd/hub"), capabilities);  

そして、これが私のテスト スイートの作成方法です。

testNames.add(SupportPortalTestSuite.class.getName());
        JUnitCore.main(testNames.toArray(new String[testNames.size()]));

また、ノードを登録すると、次のようになります。

11:28:47.403 INFO - using the json request : {"class":"org.openqa.grid.common.RegistrationRequest","capabilities":[{"platform":"LINUX","seleniumProtocol":"Selenium","browserName":"*firefox","maxInstances":5},{"platform":"LINUX","seleniumProtocol":"Selenium","browserName":"*googlechrome","maxInstances":5},{"platform":"LINUX","seleniumProtocol":"Selenium","browserName":"*iexplore","maxInstances":1},{"platform":"LINUX","seleniumProtocol":"WebDriver","browserName":"firefox","maxInstances":5},{"platform":"LINUX","seleniumProtocol":"WebDriver","browserName":"chrome","maxInstances":5},{"platform":"WINDOWS","seleniumProtocol":"WebDriver","browserName":"internet explorer","maxInstances":1}],"configuration":{"port":5555,"register":true,"host":"10.235.132.161","proxy":"org.openqa.grid.selenium.proxy.DefaultRemoteProxy","maxSession":5,"hubHost":"10.235.1.50","role":"node","registerCycle":5000,"hub":"http://10.235.1.50:4444/grid/register","hubPort":4444,"url":"http://10.235.132.161:5555","remoteHost":"http://10.235.132.161:5555"}}
11:28:47.407 INFO - starting auto register thread. Will try to register every 5000 ms.

VM で使用可能なすべてのブラウザで同時にテストを実行する必要があります。

4

2 に答える 2

0

Selenium Grid を使用すると、テストを並行して実行できますが、自動的には処理されません。これは通常、それを処理するテスト ランナーで行われます。TestNG などの一部のフレームワークにはこれが組み込まれていますが、コードによってはカスタマイズが必要になる場合があります。

于 2012-11-09T20:19:19.937 に答える
0

testNG などのいくつかのフレームワークを使用することをお勧めしますが、それらを単純な Java スレッド方式で実行することもできます。

于 2013-07-17T11:41:46.987 に答える