Selenium-键盘操作
在webdriver的Keys类中提供了键盘所有的按键操作,当然也包括一些常见的组合操作如Ctrl+A全选),Ctrl+C(复制),Ctrl+V(粘贴).更多参考官方文档对应的编码http://selenium-python.readthedocs.org/api.html
from selenium.webdriver.common.keys import keys
send_kyes(Keys.ENTER) 按下回车键
send_keys(Keys.TAB) 按下Tab键
send_keys(Keys.SPACE) 按下空格键space
send_keys(Keys.ESCAPE) 按下回退键Esc
send_keys(Keys.BACK_SPACE) 按下删除键Backspace
send_keys(Keys.SHIFT) 按下shift键
send_keys(Keys.CONTROL) 按下ctrl键
send_keys(Keys.ARROW_DOWN) 按下鼠标光标向下案件
send_keys(Keys.F6) 按下F6键
send_keys(Keys.CONTROL,"a") 按下Ctrl+A键,全选
send_keys(Keys.CONTROL,"c") 按下Ctrl+C键,复制
send_keys(Keys.CONTROL,"x") 按下Ctrl+X键,剪切
send_keys(Keys.CONTROL,"v") 按下Ctrl+V键,粘贴
eg;driver.find_element_by_id("xxxxx").send_keys(Keys.ENTER)