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
• 11,380 points
9,675 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,520 points
how do i synchronize in multiple instances?

Have a look at https://www.edureka.co/blog/selenium-grid-tutorial

Hope this helps!

Related Questions In Selenium

0 votes
1 answer
+2 votes
3 answers

How can we handle authentication popup in Selenium WebDriver using Java

1) By passing user credentials in URL. String ...READ MORE

answered Aug 30, 2020 in Selenium by Sri
• 3,010 points
21,805 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,710 points
32,069 views
0 votes
2 answers

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,520 points
5,117 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,010 points
5,847 views
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,890 points
3,608 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 2, 2020 in Selenium by Sri
• 3,010 points
4,351 views
0 votes
3 answers

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

Hi ,  Yes, you can use headless browsers ...READ MORE

answered Sep 1, 2020 in Selenium by Sri
• 3,010 points
2,132 views
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, 2019 in Selenium by Abha
• 28,040 points
951 views