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
• 9,310 points
2,090 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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,050 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,590 points
3,586 views
+3 votes
1 answer

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,590 points
7,239 views
0 votes
1 answer

Can we use Selenium to work with an already open browser session?

Yup its possible. Instead of a new ...READ MORE

answered Apr 24, 2018 in Selenium by king_kenny
• 3,590 points
3,172 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,050 points
131 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
519 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
118 views
0 votes
1 answer

Can we run selenium tests (Firefox) on WebDriver without a GUI?

You can explore options like HTMLUnit Driver ...READ MORE

answered Mar 23, 2018 in Selenium by nsv999
• 5,050 points
168 views
0 votes
1 answer

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

Download the executable driver from: ChromeDriver Download Before ...READ MORE

answered Mar 29, 2018 in Selenium by nsv999
• 5,050 points
145 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.