RSelenium RemoteDriver 未连接到端口 4445L
RSelenium RemoteDriver not connecting to port 4445L
我一直在关注这里的 Docker/RSelenium 教程:https://docs.ropensci.org/RSelenium/articles/docker.html
我已经成功托管了自己的 Selenium 服务器:
# sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0c673ba37477 selenium/standalone-chrome:88.0 "/opt/bin/entry_poin…" 3 minutes ago Up 3 minutes 5900/tcp, 0.0.0.0:4445->4444/tcp zealous_shannon
当我 运行 根据教程执行以下命令时:
library(RSelenium)
remDr <- remoteDriver(port = 4445L)
remDr$open()
我得到以下没有错误消息的输出:
[1] "Connecting to remote server"
$id
[1] NA
预期输出为:
## [1] "Connecting to remote server"
## $applicationCacheEnabled
## [1] TRUE
##
## $rotatable
## [1] FALSE
##
## $handlesAlerts
## [1] TRUE
##
## $databaseEnabled
## [1] TRUE
##
## $version
## [1] "45.0.2"
##
## $platform
## [1] "LINUX"
##
## $nativeEvents
## [1] FALSE
##
## $acceptSslCerts
## [1] TRUE
##
## $webdriver.remote.sessionid
## [1] "644c353a-34b8-4bb4-bcff-746df5a30af8"
##
## $webStorageEnabled
## [1] TRUE
##
## $locationContextEnabled
## [1] TRUE
##
## $browserName
## [1] "firefox"
##
## $takesScreenshot
## [1] TRUE
##
## $javascriptEnabled
## [1] TRUE
##
## $cssSelectorsEnabled
## [1] TRUE
##
## $id
## [1] "644c353a-34b8-4bb4-bcff-746df5a30af8"
这使我无法继续学习教程。知道为什么我通过 RemoteDriver 的连接无法正常工作吗?
为您使用的操作系统和浏览器正确设置连接参数。如果图片是基于chrome
浏览器,驱动的默认配置是firefox
.
要更改此设置,您需要添加 browserName = "chrome"
。为了清楚起见,我建议始终添加服务器的 IP 地址,因此添加 remoteServerAddr = <<server IP>>
找出驱动程序默认参数的方法是检查实例化的远程驱动程序remDr
将向您展示驱动程序的默认配置。
>remDr
$remoteServerAddr
[1] "localhost"
$port
[1] 4445
$browserName
[1] "firefox"
$version
[1] ""
$platform
[1] "ANY"
$javascript
[1] TRUE
$nativeEvents
[1] TRUE
$extraCapabilities
list()
所以在设置正确的参数后,我能够连接到公开端口上的 RSelenum。
library(RSelenium)
> remDr <- remoteDriver(
+ remoteServerAddr = "localhost",
+ port = 4445L,
+ browserName = "chrome")
> remDr$open()
[1] "Connecting to remote server"
$acceptInsecureCerts
[1] FALSE
$browserName
[1] "chrome"
$browserVersion
[1] "88.0.4324.150"
$chrome
$chrome$chromedriverVersion
[1] "88.0.4324.96 (68dba2d8a0b149a1d3afac56fa74648032bcf46b-refs/branch-heads/4324@{#1784})"
$chrome$userDataDir
[1] "/tmp/.com.google.Chrome.egZzL9"
$`goog:chromeOptions`
$`goog:chromeOptions`$debuggerAddress
[1] "localhost:36841"
$networkConnectionEnabled
[1] FALSE
$pageLoadStrategy
[1] "normal"
$platformName
[1] "linux"
$proxy
named list()
$`se:options`
$`se:options`$cdp
[1] "http://172.17.0.2:4444/session/eaed604c5fae33476755e4ba3e1c1d9e/se/cdp"
$setWindowRect
[1] TRUE
$strictFileInteractability
[1] FALSE
$timeouts
$timeouts$implicit
[1] 0
$timeouts$pageLoad
[1] 300000
$timeouts$script
[1] 30000
$unhandledPromptBehavior
[1] "dismiss and notify"
$`webauthn:extension:largeBlob`
[1] TRUE
$`webauthn:virtualAuthenticators`
[1] TRUE
$id
[1] "eaed604c5fae33476755e4ba3e1c1d9e"
我一直在关注这里的 Docker/RSelenium 教程:https://docs.ropensci.org/RSelenium/articles/docker.html
我已经成功托管了自己的 Selenium 服务器:
# sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0c673ba37477 selenium/standalone-chrome:88.0 "/opt/bin/entry_poin…" 3 minutes ago Up 3 minutes 5900/tcp, 0.0.0.0:4445->4444/tcp zealous_shannon
当我 运行 根据教程执行以下命令时:
library(RSelenium)
remDr <- remoteDriver(port = 4445L)
remDr$open()
我得到以下没有错误消息的输出:
[1] "Connecting to remote server"
$id
[1] NA
预期输出为:
## [1] "Connecting to remote server"
## $applicationCacheEnabled
## [1] TRUE
##
## $rotatable
## [1] FALSE
##
## $handlesAlerts
## [1] TRUE
##
## $databaseEnabled
## [1] TRUE
##
## $version
## [1] "45.0.2"
##
## $platform
## [1] "LINUX"
##
## $nativeEvents
## [1] FALSE
##
## $acceptSslCerts
## [1] TRUE
##
## $webdriver.remote.sessionid
## [1] "644c353a-34b8-4bb4-bcff-746df5a30af8"
##
## $webStorageEnabled
## [1] TRUE
##
## $locationContextEnabled
## [1] TRUE
##
## $browserName
## [1] "firefox"
##
## $takesScreenshot
## [1] TRUE
##
## $javascriptEnabled
## [1] TRUE
##
## $cssSelectorsEnabled
## [1] TRUE
##
## $id
## [1] "644c353a-34b8-4bb4-bcff-746df5a30af8"
这使我无法继续学习教程。知道为什么我通过 RemoteDriver 的连接无法正常工作吗?
为您使用的操作系统和浏览器正确设置连接参数。如果图片是基于chrome
浏览器,驱动的默认配置是firefox
.
要更改此设置,您需要添加 browserName = "chrome"
。为了清楚起见,我建议始终添加服务器的 IP 地址,因此添加 remoteServerAddr = <<server IP>>
找出驱动程序默认参数的方法是检查实例化的远程驱动程序remDr
将向您展示驱动程序的默认配置。
>remDr
$remoteServerAddr
[1] "localhost"
$port
[1] 4445
$browserName
[1] "firefox"
$version
[1] ""
$platform
[1] "ANY"
$javascript
[1] TRUE
$nativeEvents
[1] TRUE
$extraCapabilities
list()
所以在设置正确的参数后,我能够连接到公开端口上的 RSelenum。
library(RSelenium)
> remDr <- remoteDriver(
+ remoteServerAddr = "localhost",
+ port = 4445L,
+ browserName = "chrome")
> remDr$open()
[1] "Connecting to remote server"
$acceptInsecureCerts
[1] FALSE
$browserName
[1] "chrome"
$browserVersion
[1] "88.0.4324.150"
$chrome
$chrome$chromedriverVersion
[1] "88.0.4324.96 (68dba2d8a0b149a1d3afac56fa74648032bcf46b-refs/branch-heads/4324@{#1784})"
$chrome$userDataDir
[1] "/tmp/.com.google.Chrome.egZzL9"
$`goog:chromeOptions`
$`goog:chromeOptions`$debuggerAddress
[1] "localhost:36841"
$networkConnectionEnabled
[1] FALSE
$pageLoadStrategy
[1] "normal"
$platformName
[1] "linux"
$proxy
named list()
$`se:options`
$`se:options`$cdp
[1] "http://172.17.0.2:4444/session/eaed604c5fae33476755e4ba3e1c1d9e/se/cdp"
$setWindowRect
[1] TRUE
$strictFileInteractability
[1] FALSE
$timeouts
$timeouts$implicit
[1] 0
$timeouts$pageLoad
[1] 300000
$timeouts$script
[1] 30000
$unhandledPromptBehavior
[1] "dismiss and notify"
$`webauthn:extension:largeBlob`
[1] TRUE
$`webauthn:virtualAuthenticators`
[1] TRUE
$id
[1] "eaed604c5fae33476755e4ba3e1c1d9e"