h.stone
h.stone

Reputation: 1

TestNG: Parallel Execution: Only active window complete the test

I have setup a selenium Web driver test with TestNG to perform Parallel execution. The test starts ok, meaning that all tests start at the same time in different browser windows, but only the window, which is active (on the top), completes the test and all the other windows behind it will just stop. Does anyone know why? This is the sample XML.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite name="Suite" parallel = "classes" thread-count="2"   >
  <test name="Test">
  <classes>

      <class name = "TestCase1.ProcessWorkflow1" />
      <class name = "TestCase2.ProcessWorkflow2" />  
  </classes>


  </test> <!-- Test -->
</suite> <!-- Suite -->

Upvotes: 0

Views: 384

Answers (1)

murali selenium
murali selenium

Reputation: 3927

bit more information is required actually.. are u using grid? first start hub and node

First start the hub

java -jar selenium-server-standalone-3.XX.XX.jar -role hub

then start the node

java -Dwebdriver.chrome.driver="C:\chromedriver.exe" -jar selenium-server-standalone-3.XX.XX.jar -role webdriver -hub http://localhost:4444/grid/register

i just added chrome driver, u can add others too and use ip of machine where grid/hub started instead of localhost

here is doc https://www.selenium.dev/documentation/en/grid/ best place to learn

Now, need base class to get webdriver instance

 public class BaseTest {

protected ThreadLocal<RemoteWebDriver> threadDriver = null;

@BeforeMethod
public void setUp() throws MalformedURLException {

    threadDriver = new ThreadLocal<RemoteWebDriver>();
    hromeOptions options = new ChromeOptions();
    driver = new RemoteWebDriver(new URL("http://10.x.x.x:4444/wd/hub"), options);
    threadDriver.set(driver);
}

public WebDriver getDriver() {
    return threadDriver.get();
}

@AfterMethod
public void closeBrowser() {
    getDriver().quit();

 }
 }

here place to know chrome options https://chromedriver.chromium.org/capabilities

Now, simple test

 public class Test01 extends BaseTest{

@Test
public void testLink()throws Exception{
    getDriver().get("url");
    //to all stuff
   }
}

Upvotes: 0

Related Questions