Skip to content

TestNG Configuration

Hemanth Sridhar edited this page Apr 25, 2017 · 11 revisions

TestNG Configuration Tutorial to use WebAppFramework effectively

Mandatory : Use Selenium grid

Run your tests in different browsers

  • In order to run in chrome, add value chrome for browser parameter for the xml below
  • In order to run in firefox, add value firefox for browser parameter for the xml below
  • In order to run in safari, add value safari for browser parameter for the xml below
  • In order to run in edge, add value Microsoft Edge for browser parameter for the xml below
  • In order to run in IE, add value internet explorer for browser parameter for the xml below

Ensure that while you are setting up the node, java -Dwebdriver.chrome.driver=path till the chromedriver executable is provided. Above applies for geckodriver, safari, edge, IE

Running TestNG tests in parallel

If parallel=methods is given, all the tests mentioned in the class(in testng.xml) will run in parallel. But by just specifying parallel=methods the tests won't run in parallel. We also need to provide thread-count="5". thread-count provides the amount of threads that needs to spawned concurrently.

Also, in order to ensure that more than 5 threads are spawned, the node needs to have maxInstances=10. maxInstances is a parameter in selenium grid that defines the maximum number of sessions that can be run in a VM for every invocation.

<test name="Regression Testing">
    <parameter name="Product Name" value="Google"></parameter>
    <parameter name="Application URL" value="http://www.google.com/"></parameter>
    <parameter name="Platform" value="ANY"></parameter>
<parameter name="browser" value="chrome"></parameter>
<parameter name="Remote Url" value="http://localhost:4444/wd/hub"></parameter>
   <classes>
        <class name="org.google.modules.SearchModuleTest" ></class>
   </classes>
</test>

Clone this wiki locally