使用Selenium网格和测试套件并行执行

时间:2012-11-08 20:01:37

标签: selenium selenium-webdriver selenium-grid

我正在研究Selenium,我目前有一个集线器连接到两个运行Linux的vms和所有浏览器。

我能够启动浏览器。但是,事件我有两个vms我的所有测试都在一个vm上的单个浏览器上运行。 Selenium不会在虚拟机中启动多个浏览器。我已将最大实例设置为5,它会反映在我的gris控制台中。我有需要在linux和windows vm上运行的testsuite,它必须同时运行。我正在使用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.

我需要同时在vms上的所有可用浏览器上运行测试。

2 个答案:

答案 0 :(得分:0)

Selenium Grid使您能够并行运行测试,但不会自动处理它。这通常由一个为您处理它的测试运行器完成。像TestNG这样的一些框架具有内置功能,但可能需要根据您的代码进行一些自定义。

答案 1 :(得分:0)

虽然最好使用一些框架,例如testNG,但你也可以用普通的java Threaded方式运行它们。

相关问题