2

Not sure where am going wrong, i am trying to run same set of test one after the 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 i run this, all the test are excuted on chrome, how do i make it excute on firefox after it 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); } } 
3
  • need to know how to run hub/node Commented Jul 23, 2015 at 13:28
  • @Nguyen Vu Hoang Hub and Node are running fine Commented Jul 23, 2015 at 13:51
  • Update the code to include the driver definition, where have you implemented the driver? Commented Jul 23, 2015 at 14:22

1 Answer 1

1

Replace <suite name="Selenium Tests" parallel="false" thread-count="5"> with

<suite name="Selenium Tests" parallel="tests" thread-count="2">

All other things seems to be fine. Refer this for more info.

Edit:

I understood your problem incorrectly. The issue that you are not able to run test sequentially is due to if (driver == null). That mean your test will run well first time as driver is null, but after that due to your driver definition it may not be null and hence will not create another capability. So, if you remove it, the tests should run fine.

Sign up to request clarification or add additional context in comments.

2 Comments

this will make the test run parallely, i want the test to run serially
@ayaslem see the edit, if issue still exists you may need to add driver definition to your post as well.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.