Can I run multiple instances at the same time (simultaneously) using selenium-webdriver?

I am trying to use Selenium to automate file uploads.

I have already written a small program with selenium-webdriver that works.

The problem is that you need to download thousands of files, I would like to run several instances of the browser at the same time in order to speed up automation. So I tried something like this

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

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

I expected this to create 10 browser instances at once and do the automation at the same time.

But actually ... the above code will create a browser instance “one by one”, which means that it will not create another instance until the previous one ends.

I'v , , ...

+4
3

, , . . .

.

. , . , , .

, , , . 5 . , , .

+3

.

0

WebDriver , .

Google Chrome.

import * as webdriver from "selenium-webdriver";
import * as Chrome from 'selenium-webdriver/chrome';

function loadSelenium(){
    let options = new Chrome.Options();
    let capabilities = options.toCapabilities();
    console.log('loading another');
    return new webdriver.Builder()
        .forBrowser('chrome')
        .withCapabilities(capabilities)
        .build();
}

for(let i = 0; i < 5; i++) {
    let driver = loadSelenium();
    driver.get('http://www.google.com');
}
0

Source: https://habr.com/ru/post/1616106/


All Articles