如何使用Python在WebDriver中发送多个键?

时间:2014-04-21 21:16:10

标签: python python-2.7 selenium-webdriver webdriver sendkeys

如何在WebDriver中制作Python代码以按键盘(或键)上的Command + Shift + H按钮?

更新

info: Pushing command to appium work queue: "au.mainApp().getTreeForXML()"
debug: Sending command to instruments: au.mainApp().getTreeForXML()
info: [INSTSERVER] Sending command to instruments: au.mainApp().getTreeForXML()
info: [INSTSERVER] Socket data received (8192 bytes)
info: [INSTSERVER] Socket data received (4494 bytes)
info: [INSTSERVER] Socket data being routed for 'cmd' event
info: [INSTSERVER] Got result from instruments: {"status":0,"value":"{\"UIAApplication\":{\"@\":{\"name\":\"AppName\",\"label\":\"AppName\",\"value\":null,\"dom\":null,\"enabled\":true,\"valid\":true,\"visible\":true,\"hint\":null,\"path\":\"/0\",\"x\":0,\"y\":20,\"width\":320,\"height\":548},\">\":[{\"UIAWindow\":{\"@\":{\"name\":null,\"label\":

1 个答案:

答案 0 :(得分:7)

使用send_keys()

from selenium.webdriver.common.keys import Keys

element.send_keys(Keys.COMMAND, Keys.SHIFT, 'H')

另见:The Keys implementation