Search code examples
pythonseleniumselenium-webdriverweb-scrapingautomation

how to open multiple windows in selenium at the same time. python


am trying to open multiple windows of the same URL using selenium, I used a for loop to open the multiple windows:

for i in range(x):
    driver = web driver.Chrome(executable_path="path")
    driver.get('testing')

but the problem is that the for loop wait until each element to open and load and when it finish automating the website and then it opens the next window. I want all of the windows open simultaneously and execute simultaneously to shorten the time needed, thank you in advance.


Solution

  • Try using Selenium 4 currently in Alpha only https://pypi.org/project/selenium/4.0.0.a7/

    It provides the following for opening new windows and tabs:

    # Opens a new tab and switches to new tab
    driver.switch_to.new_window('tab')
    
    # Opens a new window and switches to new window
    driver.switch_to.new_window('window')