1

Java code in thread function,

System.setProperty("webdriver.chrome.driver", "/usr/bin/chromedriver");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--no-sandbox");
chromeOptions.addArguments("--user-data-dir="+config.chromeUserDir);
chromeOptions.addArguments("--profile-directory="+profile);
chromeOptions.addArguments("--start-maximized");
WebDriver driver = new ChromeDriver(chromeOptions);
driver.get("https://www.google.com");

and create object and start in thread with following code

Driver d1 = new Driver(profile);
d1.start();

Driver d2 = new Driver(profile1);
d1.start();

Two different profiles have been created, code works well with single thread but with multiple threads it does not open google website in two separate windows, it says:

Starting ChromeDriver 2.42.591071 (0b695ff80972cc1a65a5cd643186d2ae582cd4ac) on port 25692 Only local connections are allowed. Starting ChromeDriver 2.42.591071 (0b695ff80972cc1a65a5cd643186d2ae582cd4ac) on port 25954 Only local connections are allowed. Oct 14, 2018 2:10:46 AM org.openqa.selenium.remote.ProtocolHandshake createSession INFO: Detected dialect: OSS Oct 14, 2018 2:10:46 AM org.openqa.selenium.remote.ProtocolHandshake createSession INFO: Detected dialect: OSS Created new window in existing browser session.

It opens google in only one window. The window opened by an another thread remains idle. Could anyone please help?

3
Driver d1 = new Driver(profile);
d1.start();

Driver d2 = new Driver(profile1);
d1.start();

Here you create Driver d2 but start d1.start() the second time then (you have started it two lines of code before)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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