2

So, I've never used Selenium before and went straight to the RSelenium package for R.

I've managed to install and load the package, but can't go past calling rsDriver() function.

First problem I encountered was that my version of Chrome wasn't up-to-date, so I updated it. After that, everytime I call the function, it fails to connect to the server and says the browser didn't respod. It occurs with Chrome, Firefox and Internet Explorer, though the wording changes a bit. Let me show you:

> rsDriver(browser="firefox")
checking Selenium Server versions:
BEGIN: PREDOWNLOAD
BEGIN: DOWNLOAD
BEGIN: POSTDOWNLOAD
checking chromedriver versions:
BEGIN: PREDOWNLOAD
BEGIN: DOWNLOAD
BEGIN: POSTDOWNLOAD
checking geckodriver versions:
BEGIN: PREDOWNLOAD
BEGIN: DOWNLOAD
BEGIN: POSTDOWNLOAD
checking phantomjs versions:
BEGIN: PREDOWNLOAD
BEGIN: DOWNLOAD
BEGIN: POSTDOWNLOAD
Error in wdman::selenium(port = port, verbose = verbose, version = version,  : 
  Selenium server signals port = 4567 is already in use.

> rsDriver(browser="internet explorer")
checking Selenium Server versions:
BEGIN: PREDOWNLOAD
BEGIN: DOWNLOAD
BEGIN: POSTDOWNLOAD
checking chromedriver versions:
BEGIN: PREDOWNLOAD
BEGIN: DOWNLOAD
BEGIN: POSTDOWNLOAD
checking geckodriver versions:
BEGIN: PREDOWNLOAD
BEGIN: DOWNLOAD
BEGIN: POSTDOWNLOAD
checking phantomjs versions:
BEGIN: PREDOWNLOAD
BEGIN: DOWNLOAD
BEGIN: POSTDOWNLOAD
Error in wdman::selenium(port = port, verbose = verbose, version = version,  : 
  Selenium server signals port = 4567 is already in use.

> rsDriver()
checking Selenium Server versions:
BEGIN: PREDOWNLOAD
BEGIN: DOWNLOAD
BEGIN: POSTDOWNLOAD
checking chromedriver versions:
BEGIN: PREDOWNLOAD
BEGIN: DOWNLOAD
BEGIN: POSTDOWNLOAD
checking geckodriver versions:
BEGIN: PREDOWNLOAD
BEGIN: DOWNLOAD
BEGIN: POSTDOWNLOAD
checking phantomjs versions:
BEGIN: PREDOWNLOAD
BEGIN: DOWNLOAD
BEGIN: POSTDOWNLOAD
[1] "Connecting to remote server"
Could not open chrome browser.
Client error message:
Undefined error in httr call. httr output: Failed to connect to localhost port 4567: Connection refused
Check server log for further details.
$client
[1] "No sessionInfo. Client browser is mostly likely not opened."

$server
PROCESS 'file964483c2661.bat', running, pid 8384.
Warning message:
In rsDriver() : Could not determine server status.

I have already installed and uninstalled Chrome and restarted computer a few times. It did change the wording of the error, but not that much. I tried setting a different port a few times (4444L), but didn't help: it either said that the port was also in use or that couldn't connect to browser anyway. I have no idea what's wrong and how to fix it.

I'm using RStudio Version 1.3.1093 on a PC, Windows 7 Home Basic OS, 64x. Any help is much appreciated. Thanks.

Igor Calado
  • 39
  • 1
  • 1
  • 3
  • You could try to run with this set `driver <- rsDriver(browser=c("firefox"), port = 4445L)` I suggest you to check this answer https://stackoverflow.com/questions/43991498/rselenium-server-signals-port-is-already-in-use – Earl Mascetti Nov 23 '20 at 09:00
  • Thanks, gonna try that soon. Problem is: I've seen many of these answers and have a lot of trouble trying to grasp what's being said. This is my first time trying to run RSelenium, I have no knowledge of it yet, so the code reads like Greek to me. Also, most answers deal with cases where people can at least partially run the code, so they use the code to solve it. My problem shouldn't be with the code, I can't even call the first function successfully. – Igor Calado Nov 23 '20 at 20:00
  • Didn't work. Selenium message:Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line [...] Driver info: driver.version: unknown remote stacktrace: Could not open firefox browser. Client error message: Summary: SessionNotCreatedException Detail: A new session could not be created. Further Details: run errorDetails method Check server log for further details. – Igor Calado Nov 24 '20 at 00:19
  • You can insert port any 4 digit number ending with L.Change it if it says its already in use. Secondly, pass `chromever` argument and write the chrome driver version. `remDr <- rsDriver(port=1249L,browser = "chrome",chromever = "87.0.4280.88")` – Daman deep Dec 04 '20 at 09:13

1 Answers1

0

You can consider the two following approaches :

library(RSelenium)

shell('docker run -d -p 4446:4444 selenium/standalone-firefox') # Docker has to be installed
remDr <- remoteDriver(remoteServerAddr = "localhost", port = 4446L, browserName = "firefox")
remDr$open()
remDr$navigate("https://www.google.com")

and

library(RSelenium)
library(wdman)

port <- as.integer(4444L + rpois(lambda = 1000, 1))
pJS <- wdman::phantomjs(port = port)
remDr <- remoteDriver(browserName = "phantomjs", port = port)
remDr$open()
remDr$navigate("https://www.google.com")
Emmanuel Hamel
  • 1,769
  • 7
  • 19