Using an XML file to run multiple Web UI tests and compound tests simultaneously from the command line

You can use an XML file and the command line to run multiple Web UI tests and compound tests simultaneously on instances of Chrome and Firefox. You can also distribute these tests across multiple remote agent computers. Starting from 9.1.1.1, this feature is also available from the command line.

Before you begin

Procedure

  1. Set up an XML file similar to one of the following samples.

    Sample XML file 1

    This sample XML file lists the full path to the tests and compound tests to run and the browsers (Firefox, Chrome, or both) on which to run the tests. An XML file such as this one is supported in 9.1 and later.

    <?xml version="1.0" encoding="UTF-8"?>
      <inits>
        <tests>
          <test path="/TestProject/CompoundTests/ACompound.testsuite"/>
          <test path="/TestProject/Tests/AWebTest.testsuite"/>
        </tests>
        <browsers>
          <browser name="chrome"/>
          <browser name="firefox"/>
        </browsers>
      </inits> 

    Sample XML file 2

    Starting from 9.1.1.1, you can also list the remote agents where you can run the tests. This sample XML file automatically distributes multiple tests across different browsers, remote agents, and the local computer.

    In this sample, tests that run in Chrome use Chrome Device Mode to emulate an Apple iPhone6 Plus and a Google Nexus 5 and also run in Chrome headless mode. With headless mode, tests can run in an automated testing environment where a visible user interface shell is not required.

    <?xml version="1.0" encoding="UTF-8"?>
      <inits>   
        <group>
          <tests>	
            <test path="/WebUProj/ariesweb1.testsuite"/>
            <test path="/WebUProj/ariesweb2.testsuite"/>
            <test path="/WebUProj/ariesweb3.testsuite"/>
            <test path="/WebUProj/ariesweb4.testsuite"/>
            <test path="/WebUProj/ariesweb5.testsuite"/>
          </tests>
          <browsers>
            <browser name="chrome" devicemode="Apple iPhone 6 Plus" headless="true"/>
            <browser name="chrome" devicemode="Google Nexus 5"/>
            <browser name="firefox"/>
          </browsers>
          <locations>
            <location      host="9.113.29.29"/>
            <location      host="9.113.29.30"/>
            <location      host="9.113.29.31"/>
            <location      host="9.113.29.32"/>
            <location      host="civcez228.company1.com"/>
          </locations>
        </group>
        <group>
          <tests>	
            <test path="/WebUProj/ariesweb6.testsuite"/>
          </tests>
          <browsers>
    	 <browser name="chrome" devicemode="Apple iPhone6 Plus" headless="true"/>
    	 <browser name="firefox"/>
          </browsers>
          <locations>
    	 <location host="localhost"/>
          </locations>
       </group>	
      </inits> 
  2. If you are running tests on emulators and device clouds, edit the XML file to add the following values:
    
          <browsers>
            <browser name="<name_of_the_browser>" id="Emulator: <device_name>"/>
            <browser name="<name_of_the_browser>" id="<device_cloud_name>: <device_name>"/>
           </browsers>
    
    For example,
    
          <browsers>
            <browser name="Chrome" id="Emulator:Google_Pixel_7_Pro"/>
            <browser name="Chrome" id="BrowserStack : Google Pixel 7 Pro"/>
          </browsers>
    
  3. If you are running a compound test that contains Web UI tests and mobile tests by using a .varinit file, edit the XML file to add the values for Mobile_Device_Selection and RTW_WebUI_Browser_Selection:
    
     <?xml version="1.0" encoding="UTF-8"?>
       <inits>
        <variable_init value="BrowserStack user name" name="browserstack.username"/>
        <variable_init value="BrowserStack host URL" name="browserstack.host"/>
        <variable_init value="BrowserStack API key" name="browserstack.apikey"/>
        <variable_init value="project name" name="browserstack.project"/>
        <variable_init value="BrowserStack : device name" name="Mobile_Device_Selection"/>
        <variable_init value="Browser(BrowserStack : device name)" name="RTW_WebUI_Browser_Selection"/>
       </inits>
    
    For example,
    
     <?xml version="1.0" encoding="UTF-8"?>
       <inits>
        <variable_init value="tester_1" name="browserstack.username"/>
        <variable_init value="api-cloud.browserstack.com" name="browserstack.host"/>
        <variable_init value="KBk7PjhpqgfeVmxasUye" name="browserstack.apikey"/>
        <variable_init value="CMDLINETest" name="browserstack.project"/>
        <variable_init value="BrowserStack : Google Pixel 7 Pro" name="Mobile_Device_Selection"/>
        <variable_init value="Chrome(BrowserStack : Google Pixel 7 Pro)" name="RTW_WebUI_Browser_Selection"/>
       </inits>
    
  4. Issue the cmdline command as shown in the following example for a Windows computer. The XML file is specified in the -aftsuite argument for an AFT Suite or the varfile argument for the XML file with the .varinit extension.

Example

AFT Suite:

cmdline -workspace C:\workspaces\workspace -project Demo_Proj -plugins "C:\Program Files\HCL\HCLIMShared\plugins" -eclipsehome "C:\Program Files\HCL\DevOpsTest" -aftsuite "aftSuiteName" -results "Results\webUItest_on_off" -exportlog "C:\temp\webLog.txt"

Variable file:

cmdline -workspace C:\workspaces\workspace -project Demo_Proj -plugins "C:\Program Files\HCL\HCLIMShared\plugins" -eclipsehome "C:\Program Files\HCL\DevOpsTest" -suite Tests\myWebUITest.testsuite -varfile "C:\temp\comp.varinit"