How to send several keys in WebDriver with Python?

心不动则不痛 提交于 2019-12-21 16:55:10

问题


How to make Python code in WebDriver to press Command+Shift+H buttons on keyboard (or keys)?

Update:

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:


Use send_keys():

from selenium.webdriver.common.keys import Keys

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

Also see: The Keys implementation.



来源:https://stackoverflow.com/questions/23206174/how-to-send-several-keys-in-webdriver-with-python

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