xml - How to run test suites parallel or serially in multiple browser using selenium grid -


how run test suites parallel or serially in multiple browser using selenium grid. have 3 xml files, 1 chrome.xml(contains test run in chrome), , 1 firefox.xml(contains test run in firefox) , testng.xml contains both suites.

chrome.xml

 <suite name="chrome"> <listeners>     <listener class-name="ww5.listener.listener" /> </listeners> <test name="v5">   <parameter name="browser" value="chrome"/>   <classes>         <class name="ww5.testcases.version.version" ></class>          <class name="ww5.testcases.loginsuite.logintest" ></class>          <class name="ww5.testcases.loginsuite.logouttest" ></class>    </classes> </test> </suite> 

firefox.xml

<suite name="firefox"> <listeners>     <listener class-name="ww5.listener.listener" /> </listeners> <test name="v5">   <parameter name="browser" value="firefox"/>   <classes>         <class name="ww5.testcases.version.version" ></class>          <class name="ww5.testcases.loginsuite.logintest" ></class>          <class name="ww5.testcases.loginsuite.logouttest" ></class>    </classes> </test> </suite> 

testng.xml

<suite name="my project" parallel="tests">    <listeners>     <listener class-name="ww5.listener.listener" /> </listeners>   <suite-files>      <suite-file path="./chrome.xml" />      <suite-file path="./firefox.xml" />  </suite-files> </suite> 

thanks in advanced, using page object model hence reason suite file each browser.

  1. make webdriver thread safe.
  2. init webdriver in @beforetest , use quit() in @aftertest.

you can find example under 1 of question: parameterized selenium tests in parallel testng

update:

how make webdriver thread safe:

  private list<webdriver> webdriverpool = collections.synchronizedlist(new arraylist<webdriver>());   private threadlocal<webdriver> driverthread;    @beforetest()   public void beforetest() {       //...       this.driverthread   = new threadlocal<webdriver>() {         @override         protected webdriver initialvalue() {           webdriver webdriver = new remotewebdriver(...);           webdriverpool.add(webdriver);           return webdriver;         }       };   }    @aftertest(alwaysrun = true)   public void aftertest() {     (webdriver driver : this.webdriverpool) {       driver.quit();     }   }    // use method instead of driver.get()   public webdriver getdriver() {     return this.driverthread.get();   }  } 

Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -