Send keys not to element but in general selenium

后端 未结 1 1131
春和景丽
春和景丽 2021-01-11 09:15

Issue:

I want to send_keys(Keys.LEFT_CONTROL + \'t\') Now to do this I locate any element on the page

elem = self.browser.find_element_b         


        
相关标签:
1条回答
  • 2021-01-11 10:03

    You are using WebDriver to interact with the actual elements on the page. It will not work.

    Try using the Actions

    from selenium.webdriver.common.action_chains import ActionChains
    from selenium.webdriver.common.keys import Keys
    
    actions = ActionChains(driver)
    actions.send_keys(Keys.LEFT_CONTROL + 't')
    actions.perform()
    

    See the documentation: http://selenium-python.readthedocs.io/api.html?highlight=send_keys#module-selenium.webdriver.common.action_chains

    0 讨论(0)
提交回复
热议问题