Can we run multiple instances simultaneously with Selenium WebDriver?

0 votes

I'm trying to use Selenium to automate file uploading and I've already written a program with Selenium WebDriver that works. The problem is, there are thousands of files which need to be uploaded, I'd like to run multiple browser instances simultaneously to speed up the automation. So I tried something like this:

upload i = 0;
while (i < 10) {
    i++;
    upload driver = new webdriver.Builder()
            .forBrowser('firefox')
            .build();

    // login and upload files......
}

While I expected this to create 10 browser instances simultaneously, and upload it parallelly, the above code actually creates browser instance 'one by one' which means, it won't create another instance until the previous one finishes. I'v also tried executing the program in multiple shell instances, that will fire up multiple browser instances for me, but it doesn't work...

Mar 23, 2018 in Selenium by nitinrawat895
• 10,670 points
3,036 views

1 answer to this question.

0 votes
A better option is to create multiple threads instead of looping. You can start each upload in parallel threads instead of using selenium grid to achieve this.
You need to learn how multithreading works though.

It's not right to use grid for executing in multiple browsers parallelly. You can invoke multiple browser sessions by just creating multiple driver objects, and managing them. Each session will be separate if you want them to be. If you try executing with multiple browsers, then the performance of the system will be hampered.

Grid is preferrable only if you want to execute on remote machines and when the no. of parallel tests are in excess of 10 tests.
answered Mar 23, 2018 by nsv999
• 5,090 points

Related Questions In Selenium

+2 votes
1 answer

How can we handle authentication popup in Selenium WebDriver using Java

The Alert Method, authenticateUsing() lets us skip ...READ MORE

answered Apr 18, 2018 in Selenium by king_kenny
• 3,650 points
7,504 views
+4 votes
2 answers

Can we get the HTTP Response Code in Selenium with Java?

It is indeed possible to get http ...READ MORE

answered Apr 20, 2018 in Selenium by king_kenny
• 3,650 points
12,912 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,090 points
750 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
998 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
709 views
0 votes
2 answers
0 votes
2 answers

Can anyone help me that how to run Selenium WebDriver test cases in Chrome?

You first need to download chrome driver ...READ MORE

answered Aug 26 in Selenium by Abha
• 24,360 points
279 views