2017-08-06 57 views
1

我问和答复this question前几天,并得到Rselenium运行良好。与Rselenium,无法导航

现在我不能导航了,我不认为有任何改变,所以我感到困惑。

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 

我做了一些调试,并remDr$navigate呼叫被叫queryRD当问题发生的方法,请参见下面

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代码是char(0),而不是在我的情况下,有效的URL。并且VERB不喜欢url它的结果。

如何恢复运行?

为了得到调试在正确的地方:

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 

回答

1

您需要打开的硒服务器的连接:

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() 
+1

妈的,它必须有迷路的复制粘贴那是令人尴尬,, 非常感谢! –