【发布时间】:2018-03-14 23:09:02
【问题描述】:
我正在尝试将 RSelenium 与 Docker 一起使用,一切似乎都在工作,除了我看不到 firefox 浏览器。我认为我的代码中没有任何内容要求它是无头的,但必须如此。有没有办法让它像使用 RSelenium::startServer() 时一样可见?
我按照本文中的说明安装了 docker,https://www.raynergobran.com/2017/01/rselenium-mac-update/
我去终端输入:docker run -d -p 4445:4444 selenium/standalone-firefox 没有问题。
我转到 R 并运行此代码:
library(RSelenium)
remDr <- remoteDriver(port=4445L, browserName = "firefox")
remDr$open()
remDr$getStatus()
remDr$navigate("https://www.google.com/")
remDr$getCurrentUrl()
最后一条命令的输出如预期:
[[1]]
[1] "https://www.google.com/"
查看remDr$open()之后的输出时,headless设置为false:
[1] "Connecting to remote server"
$`moz:profile`
[1] "/tmp/rust_mozprofile.EQnMfPLPKS4l"
$rotatable
[1] FALSE
$timeouts
$timeouts$implicit
[1] 0
$timeouts$pageLoad
[1] 300000
$timeouts$script
[1] 30000
$pageLoadStrategy
[1] "normal"
$`moz:headless`
[1] FALSE
$`moz:accessibilityChecks`
[1] FALSE
$acceptInsecureCerts
[1] FALSE
$browserVersion
[1] "58.0.2"
$platformVersion
[1] "4.9.60-linuxkit-aufs"
$`moz:processID`
[1] 741
$browserName
[1] "firefox"
$platformName
[1] "linux"
$`moz:webdriverClick`
[1] TRUE
$webdriver.remote.sessionid
[1] "bfa2d87a-67d3-4e5e-838b-e6894a90dd5c"
$id
[1] "bfa2d87a-67d3-4e5e-838b-e6894a90dd5c"
同样,浏览器在我的屏幕上不可见,但我希望它可以。
我正在运行 El Capitan 10.11.6。
感谢您的帮助。
【问题讨论】:
-
嗨,冯,我试过了,但没有运气。我收到了这个错误,httr 调用中的未定义错误。 httr 输出:已达到超时:连接在 10004 毫秒后超时。我通过在终端中运行“docker inspect 7ccf58a3e085”获得了我的 Mac 上的 IP 地址。 7cc... 是容器 ID。更多信息在这里:superuser.com/a/1080158/883513
-
还有 docker.for.mac.host.internal?如stackoverflow.com/a/49149448/6309
-
嗨,冯,我没有成功运行这一行,“remoteDriver(remoteServerAddr = "docker.for.mac.host.internal", port=4445L, browserName = "firefox")" 我没看到另一个可以接受 docker.for 的字段...我在语法上遗漏了什么吗?收到的错误是:“checkError(res) 中的错误:httr 调用中的未定义错误。httr 输出:无法解析主机:docker.for.mac.host.internal”谢谢。
-
那么也许github.com/SeleniumHQ/docker-selenium/issues/511可以提供一些线索。