我尝试用RSelenium打开一个远程驱动程序,但是我仍然面对Docker同样的问题。
我在Docker内运行
$ docker run -d -p 4445:4444 selenium/standalone-firefox:2.53.0
然后
$ docker ps
Docker返回
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a89435c68373 selenium/standalone-firefox:2.53.0 "/opt/bin/entry_poin…" About an hour ago Up About an hour 0.0.0.0:4445->4444/tcp determined_sammet
然后在R
remDr <- remoteDriver(port = 4445L)
remDr$open()
我收到此错误
Error in checkError(res) :
Undefined error in httr call. httr output: Failed to connect to localhost port 4445: Connection refused
我不知道该如何处理。有人可以帮忙吗?谢谢
感谢Ralf Stubner命令
remDr <- remoteDriver(remoteServerAddr = "yourIP", port = 4445L)
已解决我的问题
答案 0 :(得分:0)
我发现介于两者之间睡眠似乎有助于避免此错误:
system("sudo docker pull selenium/standalone-chrome",wait=T)
Sys.sleep(5)
system("sudo docker run -d -p 4445:4444 selenium/standalone-chrome",wait=T)
Sys.sleep(5)
remDr <- remoteDriver(port=4445L, browserName="chrome")
Sys.sleep(15)
remDr$open()