如果虚拟机闲置,如何使用seleniumgrid将测试分配给虚拟机?

时间:2018-10-24 06:47:20

标签: selenium-grid

这是硒网格的设置。

 public WebDriver launchTargetUrl(String moduleName) throws IOException, InterruptedException {
            DesiredCapabilities cap=null;
            System.out.println(ClassName);
            try {

                //*************** Selenium Grid Setup***************//
                String nodeUrl;
                System.out.println("moduleName: " +moduleName);
                if(moduleName.equals("Distribution2")) {
                nodeUrl = "http://10.xx.xxx.xx:5555/wd/hub";

                }
                else {
                nodeUrl = "http://10.xx.xxx.xxx:5557/wd/hub";
                }
                cap = DesiredCapabilities.internetExplorer();
                cap.setCapability(CapabilityType.PLATFORM,Platform.WINDOWS );

                //*************** Selenium Grid Setup Ends***************//
                System.setProperty("webdriver.ie.driver", "./IEDriverServer.exe");
driver = new RemoteWebDriver(new URL(nodeUrl), cap);
                //Enable the below line if you are not running as Selenium Grid
                //driver = new InternetExplorerDriver();                
                driver.get(url);
                driver.manage().window().maximize();
                Thread.sleep(15000);
                return driver;
            } catch (Exception e) {
                System.out.println(e);
                return null;
            }



        }

testngXml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Parallel test suite" parallel="tests" thread-count="2">
 <test thread-count="1" name="Transaction">
  <parameter name="ClassName" value="Distribution1"></parameter>
    <classes>
      <class name="POM_Test.Distribution1"/>
     </classes>
  </test> <!-- Test -->
   <test thread-count="1" name="Alerts">
  <parameter name="ClassName" value="Distribution2"></parameter>
    <classes>
      <class name="POM_Test.Distribution2"/>
    </classes>
  </test> 
</suite> 
<!-- Suite -->

当前它正在运行Distribution1,它具有40个测试用例,而Distrbution2具有25个测试用例,并且都在不同的机器上运行。

分发2完成并处于空闲状态之后,是否可以通过分发1或

的测试用例?

我们可以采用发行版1并将40个测试用例分发到2个VM,然后采用Distirbution 2并以相同的方式进行分发。

0 个答案:

没有答案