Three browser windows are launched but all Login details are entered in single browser window. In the other two browser windows login data are not entered and the test gets failed.

It occurs for thread count greater than one.

Following are the Debugging approaches

  1. Extracted Jar file works well with Jmeter if the thread count is 1.
  2. Code works fine when launched from IDE

IDE Used: Eclipse

Project Build: Using Maven Plugin

My Test Class (Main Class)

package test.myproject.com;

import org.junit.After;
import org.junit.Before;
import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
import org.junit.Test;
import org.junit.runner.JUnitCore;

import com.myproject.baseclass.TestBase;
import com.myproject.elements.HomePage;
import com.myproject.elements.OrganisationPage;
import com.myproject.elements.SideMenu;
import com.myproject.util.Helper;

public class TestLoginPage extends TestBase {
    HomePage homepage;
    SideMenu sidemenu;
    OrganisationPage organisationpage;

    public TestLoginPage(){

    public void BrowserSetup() {

    public void MakeLogin() throws InterruptedException {   
        homepage=new HomePage();
        homepage.EnterEmail("[email protected]");

    public void CreateProject() throws InterruptedException {

        sidemenu=new SideMenu();
        organisationpage=new OrganisationPage();

    public void TearDown() {

    public static void main(String[] args) {
        //JUnitCore junit = new JUnitCore();
        //junit.addListener(new TextListener(System.out));
        //Result result = junit.run(TestLoginPage.class);  

Class will be declared in Testbase.java class

package com.myproject.baseclass;

import java.io.File;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.WebDriverWait;

public class TestBase {
    public Properties prop;
    public FileInputStream file;
    public static WebDriver driver;
    public static WebDriverWait wait;

    public TestBase() {
        try {
            prop = new Properties();
            file = new FileInputStream("Z:/myproject/assets/property/myproject.properties");
            //data=new ArrayList<String>();
        } catch (Exception e) {


    public void intialization() {
        if (prop.getProperty("browser").contentEquals("chrome")) {
            System.setProperty("webdriver.chrome.driver",new File("Z:/myproject/assets/driver/chromedriver.exe").getAbsolutePath());
            driver = new ChromeDriver();
        } else {
            System.out.println("No browser found");

        try {
            driver.manage().timeouts().pageLoadTimeout(20, TimeUnit.SECONDS);
            driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);

        } catch (Exception e) {
            System.out.println("Alert Site seems very slow!!!! Please increase the page load time out in util class");

  • blazemeter.com/blog/mixing-selenium-into-your-load-scenario i don't think this is possible , most documents says that the selelnium scripts execute in only one browser at a time
    – PDHide
    Feb 27, 2020 at 13:56
  • @PDHide but when i run selenium in Jmeter using Webdriver sampler plugin it works fine only if i run from Junit issue occurs Feb 28, 2020 at 4:44
  • Can you put the code
    – PDHide
    Feb 28, 2020 at 6:10
  • @PDHide code will not work as the application hosted in our local server i will make a sample script of any other website and send you the code Feb 28, 2020 at 6:16
  • I meant the code showing how you call jmeter from junit
    – PDHide
    Feb 28, 2020 at 6:36

1 Answer 1


It's hard to say what's wrong without seeing your intialization(); function, most probably you're facing some form of a race condition

As per WebDriver FAQ:

Q: Is WebDriver thread-safe?

A: WebDriver is not thread-safe. Having said that, if you can serialise access to the underlying driver instance, you can share a reference in more than one thread. This is not advisable. You /can/ on the other hand instantiate one WebDriver instance for each thread.

Most probably in your case 3 threads are trying to work with a single WebDriver instance (for example you declared it as static)

If you are not feeling too comfortable with multi-threading in Java I would recommend considering switching to WebDriver Sampler plugin or at least check its source code to learn how to properly initialize WebDriver instances so they would be independent and thread-safe

  • I have updated my answer with my base class source code(class which has initialization method) Mar 2, 2020 at 11:41
  • I was telepathic enough to guess that your WebDriver declaration is static, you cannot use static fields safely when it comes to multithreading.
    – Dmitri T
    Mar 2, 2020 at 11:54
  • thank you the issue is because of the static declaration Now its working for me Mar 2, 2020 at 12:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.