Send Ctrl+f python selenium chrome

▼魔方 西西 提交于 2021-02-08 07:56:10

问题


I am able to use some keys like Tab

browser.find_element_by_tag_name('body').send_keys(Keys.TAB)

But not Ctrl+f or Ctrl+p

browser.find_element_by_tag_name('body').send_keys(Keys.CONTROL +'f')

I also tried using xpath find_element_by_xpath & send_keys(Keys.CONTROL,'f') but still not working


回答1:


You shall try by using action_chains in selenium webdriver

from selenium.webdriver.common.action_chains import ActionChains
#
# Your code
#
browser.find_element_by_tag_name('body')
ActionChains(browser).send_keys(Keys.CONTROL, "f").perform()


来源:https://stackoverflow.com/questions/43884979/send-ctrlf-python-selenium-chrome

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!