ropensci / RSelenium

An R client for Selenium Remote WebDriver

Home Page:https://docs.ropensci.org/RSelenium

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Does RSelenium handle hotkeys?

Camilo-Mora opened this issue · comments

I was not able to find a solution on the web about this. So I am trying here.

The question is, can RSelenium handle hotkeys? I noted that only the control + a hot key works... but all others do not.

Hotkeys is a practical solution to activate extensions, or run operations outside DOM, which are complicated to handle with Selenium...

Below I show some examples of hotkeys that should operate in any chrome browser. I put them as examples of shortcuts that work when entered manually but not when using Rselenium... they are just as reference for the problem. My particular need is to activate a Extension that uses Control+Shift+S as shortcut.

library(RSelenium)
rD <- rsDriver(browser = "firefox") 

remDr <- rD$client
remDr$navigate("https://www.google.com")

remDr$navigate("https://www.amazon.com")

#use hot key to see history of visiting the two pages above.
elem <- remDr$findElement("xpath", "//body")
elem$sendKeysToElement(list(key = 'control',  'H'))

#here is another example with three keys. This one should reload the page
#the reload shortcut control+shift+R
elem$sendKeysToElement(list(key = 'control',  key = 'shift','R'))

#it is very intriguing that the select all shortcut, control + a, works well.
webElem$sendKeysToElement(list(key = "control", "a"))