Parallel execution of Selenium WebDriver test cases gives blank screen in response

edited April 2016 in Selenium
I have prepared Selenium WebDriver script to test a web application, when I execute a single test / sequential tests, the result is correct and no screen response is blank.
When I execute the same method in parallel, eg 2 chrome instances, then in one of the browsers , atleast one screen response is blank because of which the test fails.
I am not using Selenium Grid, only Webdriver to execute multiple tests in parallel on one system.

Here is a sample example of what i am trying to do.
This example works fine , but when I use this same for my application, screen response is blank.
public class DemoTest {
private static final ThreadLocal webDriverThreadLocal= new InheritableThreadLocal<>();
@BeforeMethod
public void beforeMethod() {
WebDriver driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
driver.manage().window().maximize();
webDriverThreadLocal.set(driver);
System.out.println("In before method:"+Thread.currentThread().getId());
System.out.println("FF hashcode:"+driver.hashCode());
}

@DataProvider(name = "data-provider", parallel=true)
public Object[][] dataProviderMethod() throws IOException {
System.out.println("On dp");
return new Object[][]{{1, "a"}, {2, "b"}};
}
@Test(dataProvider = "data-provider")
public void test(Integer n, String s) {
String baseUrl;
String severity;
WebDriver driver = webDriverThreadLocal.get();
baseUrl = "http://www.google.com/";
driver.get(baseUrl);
System.out.println("method f id:"+Thread.currentThread().getId()+" n:"+n+" s:"+s);
//test continues
}
@AfterMethod
public void afterMethod() {
WebDriver driver = webDriverThreadLocal.get();
System.out.println("In after method for id:"+Thread.currentThread().getId());
driver.quit();
}
}

Leave a Comment