rseleniumrseleniumhttp-verbs

with Rselenium, can't navigate anymore


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

Solution

  • 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()