2

I have the following code with which I try to open the url into a new tab every take a new url loaded from the for loop open to a new tab. What I made until know is this:

library("RSelenium")
startServer()
checkForServer()
remDr <- remoteDriver()
remDr$open()
remDr$navigate("http://www.google.com/")
Sys.sleep(5)
myurllist <- c("https://cran.r-project.org/", "http://edition.cnn.com/", "https://cran.r-project.org/web/packages/")

for (i in 1:length(myurllist)) {
  url <- url_list[i]
  webElem <- remDr$findElement("css", "urlLink")
  webElem$sendKeysToElement(list(key = "t"))
  remDr$navigate(url)
  Sys.sleep(5)
}

From selenium I found this answer

Community
  • 1
  • 1
Berbery
  • 297
  • 2
  • 4
  • 12

1 Answers1

4

A new tab is opened by pressing CTRL+T, not T:

library("RSelenium")
startServer()
checkForServer()
remDr <- remoteDriver()
remDr$open()
remDr$navigate("http://www.google.com/")
url_list <- c("http://edition.cnn.com/", "https://cran.r-project.org/web/packages/")
for (url in url_list) {
  webElem <- remDr$findElement("css", "html")
  webElem$sendKeysToElement(list(key="control", "t"))
  remDr$navigate(url)
}
lukeA
  • 53,097
  • 5
  • 97
  • 100