Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 98800

How to run multiple instances of Chrome parallely with webdriver in python?

$
0
0

Hi I try to open parallely multiple instances of Chrome in python using Webdriver and Multiprocessing. After running processes, instances are opening smoothly, but they are not sent to my "instance" array and I can't access instances after that. Please help me, there is my code:

from selenium import webdriver
from multiprocessing import Process
import time

num = 3

process = [None] * num
instance = [None] * num

def get():

    for i in range(num):
        try:
            instance[i].get("https://www.youtube.com")
        except:
            print("Can't connect to the driver")

    time.sleep(1)
    get()

def create_instance(i):
    instance[i] = webdriver.Chrome()


if __name__ == '__main__':

    for i in range(num):
        process[i] = Process(target = create_instance, args = [i])
        process[i].start()

    for i in range(num):
        process[i].join()

    get()

Viewing all articles
Browse latest Browse all 98800


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>