Send keys control + click in Selenium with Python bindings

前端 未结 6 861
甜味超标
甜味超标 2020-12-01 00:54

I need to open link in new tab using Selenium.

So is it possible to perform ctrl+click on element in Selenium to open it in new tab?

6条回答
  •  感动是毒
    2020-12-01 01:35

    Two possible solutions:

    opening a new tab

    self.driver = webdriver.Firefox()
    self.driver.find_element_by_tag_name('body').send_keys(Keys.COMMAND + 't') 
    

    this is the solution for MAC OSX. In other cases you can use the standard Keys.CONTROL + 't'

    opening a new webdriver

    driver = webdriver.Firefox() #1st window
    second_driver = webdriver.Firefox() #2nd windows 
    

提交回复
热议问题