2

I asked and answer this question a few days ago and got Rselenium running fine.

now I can't navigate anymore, I don't think anything changed so I'm puzzled.

shell('docker run -d -p 4445:4444 selenium/standalone-chrome')
remDr <- remoteDriver(remoteServerAddr = "localhost", port = 4445L, browserName = "chrome")
remDr$navigate("http://www.google.com") # used to work
# Error in checkError(res) : 
#   Undefined error in httr call. httr output: length(url) == 1 is not TRUE

I did a bit of debugging, and remDr$navigate calls a method called queryRD where the issue happens, see the code below

debugging in: queryRD(qpath, "POST", qdata = list(url = url))
debug: {
    "A method to communicate with the remote server implementing the \\n          JSON wire protocol."
    getUC.params <- list(url = ipAddr, verb = method, body = qdata, 
        encode = "json")
    res <- tryCatch({
        do.call(httr::VERB, getUC.params) # VERB doesn't like the url argument its getting
    }, error = function(e) {
        e
    })
    if (inherits(res, "response")) {
        resContent <- httr::content(res, simplifyVector = FALSE)
        checkStatus(resContent)
    }
    else {
        checkError(res)
    }
}

ipAddr is a char(0) instead of a valid url in my case. And VERB doesn't like the url argument it's getting as a consequence.

How do I get it back running as before ?

To get the debug at the right place:

shell('docker run -d -p 4445:4444 selenium/standalone-chrome')
    remDr <- remoteDriver(remoteServerAddr = "localhost", port = 4445L, browserName = "chrome")
debugonce(remDr$navigate)
remDr$navigate("http://www.google.com")
debugonce(queryRD)
c
moodymudskipper
  • 46,417
  • 11
  • 121
  • 167

2 Answers2

1

You need to open the connection to the Selenium server:

library(RSelenium)

remDr <- remoteDriver(remoteServerAddr = "localhost", port = 4445L, 
                      browserName = "chrome")
remDr$open()
remDr$navigate("http://www.google.com") # used to work
> remDr$getTitle()
[[1]]
[1] "Google"
...

remDr$close()
jdharrison
  • 30,085
  • 4
  • 77
  • 89
1

For RSelenium users running without Docker and encountering the error

Error in checkError(res) : 
  Undefined error in httr call. httr output: length(url) == 1 is not TRUE

Use,

remDr <- driver[["client"]]
remDr$navigate("http://www.google.com")

after launching browser

remDr <- remoteDriver(browserName = "chrome")
Nad Pat
  • 3,129
  • 3
  • 10
  • 20