java - How do I run selenium test one after the other on multiple browser -
not sure going wrong, trying run same set of test 1 after other on multiple browser.
testng.xml
<suite name="selenium tests" parallel="false" thread-count="5"> <listeners> <listener class-name="ww5.listener.listener" /> </listeners> <test name="chrome" preserve-order="true"> <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> <test name="firefox" preserve-order="true"> <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>
when run this, test excuted on chrome, how make excute on firefox after finish excuting on chrome.
openbrowser.java
@parameters ({"browser"}) @beforeclass public void launchbrowser(string browser) throws exception { //initlogs(this.getclass()); initconfigurations(); if (driver == null) { desiredcapabilities cap = null; if(browser.equalsignorecase("firefox")) { cap = desiredcapabilities.firefox(); cap.setbrowsername("firefox"); //cap.setplatform(org.openqa.selenium.platform.windows); } if(browser.equalsignorecase("internet explorer")) { cap = desiredcapabilities.internetexplorer(); cap.setbrowsername("internet explorer"); cap.setplatform(org.openqa.selenium.platform.any); } if(browser.equalsignorecase("chrome")) { cap = desiredcapabilities.chrome(); cap.setbrowsername("chrome"); cap.setplatform(org.openqa.selenium.platform.any); } driver = new remotewebdriver(new url("http://localhost:4444/wd/hub"), cap); driver.manage().window().maximize(); driver.manage().timeouts().implicitlywait(30, timeunit.seconds); wait = new webdriverwait(driver,30); } }
replace <suite name="selenium tests" parallel="false" thread-count="5">
<suite name="selenium tests" parallel="tests" thread-count="2">
all other things seems fine. refer this more info.
edit:
i understood problem incorrectly. issue not able run test sequentially due if (driver == null)
. mean test run first time driver null, after due driver definition may not null
, hence not create capability. so, if remove it, tests should run fine.
Comments
Post a Comment