【问题标题】:how to open multiple windows in selenium at the same time. python [duplicate]如何同时在 selenium 中打开多个窗口。蟒蛇[重复]
【发布时间】:2021-03-07 20:08:25
【问题描述】:

我正在尝试使用 selenium 打开同一 URL 的多个窗口, 我使用了一个 for 循环来打开多个窗口:

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

但问题是 for 循环会等到每个元素打开和加载,当它完成网站自动化时,它会打开下一个窗口。我希望所有窗口同时打开并同时执行以缩短所需时间,提前谢谢。

【问题讨论】:

    标签: python selenium selenium-webdriver web-scraping automation


    【解决方案1】:

    尝试使用目前仅处于 Alpha 阶段的 Selenium 4 https://pypi.org/project/selenium/4.0.0.a7/

    它为打开新窗口和标签提供了以下功能:

    # 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')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-06
      • 1970-01-01
      • 2020-02-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多