0

I'm creating a scraper with Rselenium and phantomjs. Sometime my program querying a web-site take too long and never end. So I'm writing a time-out handler.

library(RSelenium)
library(R.utils)
pJS <- phantom(pjs_cmd ="C:\\software\\phantomjs-2.0.0-windows\\bin\\phantomjs.exe"     )
UA<-'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0'
eCap <- list(phantomjs.page.settings.userAgent=UA )
remDr <- remoteDriver(browserName = "phantomjs", extraCapabilities = eCap)
remDr$open(silent=T)

time_out<-0
tryCatch({withTimeout({
        remDr$navigate("http://stackoverflow.com/questions/14399205/in-r-how-to-make-the-variables-inside-a-function-available-to-the-lower-level-f")
                                      }, envir=globalenv(),timeout=1.08);
                            }, TimeoutException=function(ex) {
            time_out<<-1
})

But I get the error : Undefined error in RCurl call.Error in queryRD(paste0(serverURL, "/session/", sessionInfo$id, "/url"), :

Anyway if I try to look inside remDr ...

remDr$getTitle()[[1]]
[1] "In R, how to make the variables inside a function available to the lower level function inside this function?(with, attach, environment) - Stack Overflow"

So It worked! But why I get the error?

dax90
  • 1,088
  • 14
  • 29

1 Answers1

0

Please update JAVA and check the Selenium Version whether the webdriver is running with the newest version. That solves the issue

Bharath
  • 1,600
  • 14
  • 25