0
votes

I am beginner in selenium webdriver. so for parallel execution normally we do changes in xml file like parallel="methods" thread-count="3" and my doubt is:

Is the parallel execution possible without selenium grid? or only testNG is enough?

2

2 Answers

2
votes

Yes, you may run UI tests in parallel without grid, or using only selenium grid node directly, without hub. Each thread in TestNG will open additional browser window, but you will get unpredictable issues in case when you application will manage all connections from you host as one user session.

0
votes

Yes, using @Parameters ("browser") of TestNg..sample code as below...

 @Parameters ("browser")
  public void test(String browserName) {
      if(browserName.equalsIgnoreCase("firefox")){
          driver = new FirefoxDriver();

      } else if (browserName.equalsIgnoreCase("chrome")){
          System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir")+"\\chromedriver.exe" );
          driver = new ChromeDriver();
      }
  }

write your test after that in your testng.xml use parallel option also mention the parameter value.. sample code as below..

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite789787" parallel="tests">
  <test name="FFTest98798">
  <parameter name="browser" value="firefox"/>   

  <classes>
    <class name ="crossbrowsertest.VerifyTitle" >
    </class>
  </classes>
  </test> <!-- Test -->

  <test name="ChromeTest8999">
    <parameter name="browser" value="chrome"/>  

  <classes>
    <class name ="crossbrowsertest.VerifyTitle" >
    </class>
  </classes>
  </test>   <!-- Test -->
</suite> <!-- Suite -->

hope this helps