webdriver for python模拟键盘操作

来源:互联网 发布:淘宝盗用别人3c认证 编辑:程序博客网 时间:2024/06/06 02:40

引用下面两个包

from selenium.webdriver.common.keys import Keysfrom selenium.webdriver.common.action_chains import ActionChains

键盘组合ctrl+c,ctrl+x等

ActionChains(self.driver).key_down(Keys.CONTROL).send_keys('c').key_up(Keys.CONTROL).perform()ActionChains(self.driver).key_down(Keys.CONTROL).send_keys('x').key_up(Keys.CONTROL).perform()

单个按键

ActionChains(self.driver).key_down(Keys.ENTER).perform()ActionChains(self.driver).key_down(Keys.DELETE).perform()
0 0