How to press two keys simultaneously (i.e., control-s) in a webpage using RSelenium?

牧云@^-^@ 提交于 2021-01-27 21:50:00

问题


Let's say I want to select all on a page, copy all or save a page, what is the proper command for RSelenium? The example below seems to press the keys in sequence, what I'm trying to do is tell it to hold the "control" key while it presses "s"

library(RSelenium)
driver <- rsDriver()
remDr <- driver[["client"]]
remDr$navigate("https://www.google.com/")
remDr$sendKeysToActiveElement(list(key = "control", "s"))

回答1:


You need to choose element first:

webElem <- remDr$findElement("css", "html")
webElem$sendKeysToElement(list(key = "control", "s"))

Tested it with list(key = "control", "a") and looks like such construction should work as simultaneous keys.



来源:https://stackoverflow.com/questions/46322715/how-to-press-two-keys-simultaneously-i-e-control-s-in-a-webpage-using-rselen

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