Testing AUT with Different Browsers

The type of browser to be used to run your model is defined in the model node property. If you run the model with multiple virtual users, all virtual users will be started with the same browser selected for the model.

What if you want to have a bunch virtual users running Firefox and the others running IE with a single model execution?

There are several ways to dynamically change the browser type.

You can dynamically change the type of browser for each of the virtual user thread by calling mScript method $setBrowserCmd('browser cmd') before the AUT is open.

This is typically done by placing $setBrowserCmd('browser') in MBT_start trigger.

However this is still hardcoded to a specific browser. To start AUT using different browser for different virtual user, you can use random number generation function $rand(int) and an if tag to set the browser when the random number generated is within certain range:

  <action code="$setBrowserCmd('iexplore')"/>
  <if value1="$rand(10)" op="gt" value2="5">
     <action code="$setBrowserCmd('firefox')"/>
  </if>

A better alternative is to store a list of browser cmd in a dataset and use $nextDataSetRow('dsName', '$rand()') to position the dataset randomly on a row in the dataset and retrieve it to set the browser cmd as follows:

   <action code="$nextDataSetRow('browserList', '$rand()')"/>
   <action code="$setBrowserCmd('$getData('browserList', 'browserID')')"/>

Here we assume you have created a dataset called browserList that has a field called browserID populated with iexplore, firefox, etc.

You can use the later approach to change the proportion of the virtual users to run each type of the browser by adding more rows of one browser than the other.

Another alternative is to use $randFromList('iexplorer,firefox,opera') to randomly select a browser from the predefined list:

   <action code="$setBrowserCmd('$randFromList('iexplorer,firefox,opera')')"/>

All of the above methods are all viable option. Feel free to choose one as appropriate for your needs and preference.

Print/export
QR Code
QR Code faq_dynamic_change_of_browser (generated for current page)