我几天前问了并回答了this question并让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)
而不是有效的网址。并且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
答案 0 :(得分:1)
您需要打开与Selenium服务器的连接:
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()