Я попытался подключиться к сетке селена в docker из R и не удалось. Я могу подключиться через Python, однако. В чем проблема с моим кодом R, приведенным ниже, по сравнению с успешным кодом Python?
Это мой dockerfile:
# To execute this docker-compose yml file use `docker-compose -f <file_name> up`
# Add the `-d` flag at the end for detached execution
version: "3"
services:
selenium-hub:
image: selenium/hub:3.141.59-zinc
container_name: selenium-hub
ports:
- "4444:4444"
chrome:
image: selenium/node-chrome:3.141.59-zinc
volumes:
- /dev/shm:/dev/shm
depends_on:
- selenium-hub
environment:
- HUB_HOST=selenium-hub
- HUB_PORT=4444
firefox:
image: selenium/node-firefox:3.141.59-zinc
volumes:
- /dev/shm:/dev/shm
depends_on:
- selenium-hub
environment:
- HUB_HOST=selenium-hub
- HUB_PORT=4444
Этот код для подключения к нему через Python работает:
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
firefox = webdriver.Remote(
command_executor='http://localhost:4444/wd/hub',
desired_capabilities=DesiredCapabilities.FIREFOX)
firefox.get('https://www.google.com')
print(firefox.title)
firefox.quit()
Эта попытка с RSelenium от R не удалась:
library(RSelenium)
remDr <- remoteDriver(
remoteServerAddr = "localhost",
port = 4444L
browserName = 'firefox'
)
remDr$open()
remDr$navigate('https://google.com')
возвращает:
[1] "Connecting to remote server"
$id
[1] NA
Selenium message:Session [NA] not available and is not among the last 1000 terminated sessions.
Active sessions are[ext. key 458ca8f3-086a-4068-845f-5cbe61d11e84]
Error: Summary: UnknownError
Detail: An unknown server-side error occurred while processing the command.
class: org.openqa.grid.common.exception.GridException
Further Details: run errorDetails method
и это журнал в docker:
Creating network "desktop_default" with the default driver
Creating selenium-hub ... done Creating desktop_chrome_1 ... done Creating desktop_firefox_1 ... done Attaching to selenium-hub, desktop_chrome_1, desktop_firefox_1
selenium-hub | 2020-02-10 02:55:20,416 INFO Included extra file "/etc/supervisor/conf.d/selenium-hub.conf" during parsing
selenium-hub | 2020-02-10 02:55:20,417 INFO supervisord started with pid 12
chrome_1 | 2020-02-10 02:55:21,057 INFO Included extra file "/etc/supervisor/conf.d/selenium.conf" during parsing
chrome_1 | 2020-02-10 02:55:21,058 INFO supervisord started with pid 8
firefox_1 | 2020-02-10 02:55:21,107 INFO Included extra file "/etc/supervisor/conf.d/selenium.conf" during parsing
firefox_1 | 2020-02-10 02:55:21,108 INFO supervisord started with pid 7
selenium-hub | 2020-02-10 02:55:21,421 INFO spawned: 'selenium-hub' with pid 15
selenium-hub | Starting Selenium Hub with configuration:
selenium-hub | 2020-02-10 02:55:21,432 INFO success: selenium-hub entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
selenium-hub | {
selenium-hub | "host": "0.0.0.0",
selenium-hub | "port": 4444,
selenium-hub | "role": "hub",
selenium-hub | "maxSession": 5,
selenium-hub | "newSessionWaitTimeout": -1,
selenium-hub | "capabilityMatcher": "org.openqa.grid.internal.utils.DefaultCapabilityMatcher",
selenium-hub | "throwOnCapabilityNotPresent": true,
selenium-hub | "jettyMaxThreads": -1,
selenium-hub | "cleanUpCycle": 5000,
selenium-hub | "browserTimeout": 0,
selenium-hub | "timeout": 1800,
selenium-hub | "debug": false
selenium-hub | }
selenium-hub | 02:55:21.619 INFO [GridLauncherV3.parse] - Selenium server version: 3.141.59, revision: e82be7d358
selenium-hub | 02:55:21.689 INFO [GridLauncherV3.lambda$buildLaunchers$5] - Launching Selenium Grid hub on port 4444
selenium-hub | 2020-02-10 02:55:22.047:INFO::main: Logging initialized @611ms to org.seleniumhq.jetty9.util.log.StdErrLog
chrome_1 | 2020-02-10 02:55:22,060 INFO spawned: 'xvfb' with pid 11
chrome_1 | 2020-02-10 02:55:22,061 INFO spawned: 'selenium-node' with pid 12
firefox_1 | 2020-02-10 02:55:22,110 INFO spawned: 'xvfb' with pid 10
firefox_1 | 2020-02-10 02:55:22,111 INFO spawned: 'selenium-node' with pid 11
chrome_1 | Connecting to the Hub using the host selenium-hub and port 4444
chrome_1 | 2020-02-10 02:55:22,146 INFO success: xvfb entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
chrome_1 | 2020-02-10 02:55:22,147 INFO success: selenium-node entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
firefox_1 | Connecting to the Hub using the host selenium-hub and port 4444
firefox_1 | 2020-02-10 02:55:22,152 INFO success: xvfb entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
firefox_1 | 2020-02-10 02:55:22,152 INFO success: selenium-node entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
selenium-hub | 02:55:22.327 INFO [Hub.start] - Selenium Grid hub is up and running
selenium-hub | 02:55:22.328 INFO [Hub.start] - Nodes should register to http://192.168.112.2:4444/grid/register/
selenium-hub | 02:55:22.328 INFO [Hub.start] - Clients should connect to http://192.168.112.2:4444/wd/hub
chrome_1 | 02:55:22.522 INFO [GridLauncherV3.parse] - Selenium server version: 3.141.59, revision: e82be7d358
firefox_1 | 02:55:22.568 INFO [GridLauncherV3.parse] - Selenium server version: 3.141.59, revision: e82be7d358
chrome_1 | 02:55:22.681 INFO [GridLauncherV3.lambda$buildLaunchers$7] - Launching a Selenium Grid node on port 5555
firefox_1 | 02:55:22.724 INFO [GridLauncherV3.lambda$buildLaunchers$7] - Launching a Selenium Grid node on port 5555
chrome_1 | 2020-02-10 02:55:22.798:INFO::main: Logging initialized @641ms to org.seleniumhq.jetty9.util.log.StdErrLog
firefox_1 | 2020-02-10 02:55:22.840:INFO::main: Logging initialized @683ms to org.seleniumhq.jetty9.util.log.StdErrLog
chrome_1 | 02:55:23.061 INFO [WebDriverServlet.<init>] - Initialising WebDriverServlet
firefox_1 | 02:55:23.106 INFO [WebDriverServlet.<init>] - Initialising WebDriverServlet
chrome_1 | 02:55:23.162 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 5555
chrome_1 | 02:55:23.162 INFO [GridLauncherV3.lambda$buildLaunchers$7] - Selenium Grid node is up and ready to register to the hub
firefox_1 | 02:55:23.220 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 5555
firefox_1 | 02:55:23.221 INFO [GridLauncherV3.lambda$buildLaunchers$7] - Selenium Grid node is up and ready to register to the hub
chrome_1 | 02:55:23.238 INFO [SelfRegisteringRemote$1.run] - Starting auto registration thread. Will try to register every 5000 ms.
firefox_1 | 02:55:23.298 INFO [SelfRegisteringRemote$1.run] - Starting auto registration thread. Will try to register every 5000 ms.
firefox_1 | 02:55:23.677 INFO [SelfRegisteringRemote.registerToHub] - Registering the node to the hub: http://selenium-hub:4444/grid/register
chrome_1 | 02:55:23.691 INFO [SelfRegisteringRemote.registerToHub] - Registering the node to the hub: http://selenium-hub:4444/grid/register
firefox_1 | 02:55:23.733 INFO [SelfRegisteringRemote.registerToHub] - The node is registered to the hub and ready to use
selenium-hub | 02:55:23.734 INFO [DefaultGridRegistry.add] - Registered a node http://192.168.112.4:5555
chrome_1 | 02:55:23.734 INFO [SelfRegisteringRemote.registerToHub] - The node is registered to the hub and ready to use
selenium-hub | 02:55:23.738 INFO [DefaultGridRegistry.add] - Registered a node http://192.168.112.3:5555
selenium-hub | 02:55:42.228 INFO [RequestHandler.process] - Got a request to create a new session: Capabilities {browserName: firefox, javascriptEnabled: true, nativeEvents: true, version: }
selenium-hub | 02:55:42.232 INFO [TestSlot.getNewSession] - Trying to create a new session on test slot {server:CONFIG_UUID=3877e360-52c7-4e64-823f-14a77e0d41a1, seleniumProtocol=WebDriver, browserName=firefox, maxInstances=1, moz:firefoxOptions={log={level=info}}, platformName=LINUX, version=72.0.1, applicationName=, platform=LINUX}
firefox_1 | 02:55:42.286 INFO [ActiveSessionFactory.apply] - Capabilities are: {
firefox_1 | "browserName": "firefox",
firefox_1 | "javascriptEnabled": true,
firefox_1 | "nativeEvents": true,
firefox_1 | "version": ""
firefox_1 | }
firefox_1 | 02:55:42.288 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.firefox.GeckoDriverService)
firefox_1 | 1581303342347 mozrunner::runner INFO Running command: "/usr/bin/firefox" "-marionette" "-foreground" "-no-remote" "-profile" "/tmp/rust_mozprofilehByv3X"
firefox_1 | 1581303342649 addons.webextension.doh-rollout@mozilla.org WARN Loading extension 'doh-rollout@mozilla.org': Reading manifest: Invalid extension permission: networkStatus
firefox_1 | 1581303342761 addons.webextension.screenshots@mozilla.org WARN Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: mozillaAddons
firefox_1 | 1581303342761 addons.webextension.screenshots@mozilla.org WARN Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: telemetry
firefox_1 | 1581303342764 addons.webextension.screenshots@mozilla.org WARN Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: resource://pdf.js/
firefox_1 | 1581303342764 addons.webextension.screenshots@mozilla.org WARN Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: about:reader*
firefox_1 | 1581303344155 Marionette INFO Listening on port 35231
firefox_1 | 02:55:44.192 INFO [ProtocolHandshake.createSession] - Detected dialect: W3C
firefox_1 | 02:55:44.216 INFO [RemoteSession$Factory.lambda$performHandshake$0] - Started new session 458ca8f3-086a-4068-845f-5cbe61d11e84 (org.openqa.selenium.firefox.GeckoDriverService)
Он успешно открывает браузер, но не может подключиться .