Open web in new tab Selenium + Python

后端 未结 11 2202
别跟我提以往
别跟我提以往 2020-11-22 01:15

So I am trying to open websites on new tabs inside my WebDriver. I want to do this, because opening a new WebDriver for each website takes about 3.5secs using PhantomJS, I w

11条回答
  •  醉话见心
    2020-11-22 01:37

    After struggling for so long the below method worked for me:

    driver.find_element_by_tag_name('body').send_keys(Keys.CONTROL + 't')
    driver.find_element_by_tag_name('body').send_keys(Keys.CONTROL + Keys.TAB)
    
    windows = driver.window_handles
    
    time.sleep(3)
    driver.switch_to.window(windows[1])
    

提交回复
热议问题