Search code examples
rrselenium

Error using rsDriver of the RSelenium package in R


I am trying to open a browser using the RSelenium package in R.

When using this command

rs_driver_object <- rsDriver(browser="chrome", 
                             chromever = "113.0.5672.63",
                             verbose = F,
                             port=free_port())

I get this error

Error in gsub("\\s+", ",", ActiveConnections) : input string 1 is invalid
In addition: Warning message:
In gsub("\\s+", ",", ActiveConnections) :
  unable to translate '  Proto  Adresse locale         Adresse distante       <90>tat' to a wide string

Here are the first lines of my code, they work well

library(tidyverse)
library(RSelenium)
library(netstat)
library(wdman)

# To download chromedriver
selenium()

# To find where chromedriver is installed
selenium_object <- selenium (retcommand = T, check = F)

# Versions to use
binman::list_versions("chromedriver")

Here is my Google Chrome version : 113.0.5672.127

and here is the result of the line with binman :

$win32
 "113.0.5672.24" "113.0.5672.63" "114.0.5735.16"

So using the 113.0.5672.63 version of chromedriver should work.

I think the error comes from free_port() which allows me to find a free port. I have tried not to use but if I don't say which port I'm using or if I use a random port, it can tell me that the port is already in use and so it doesn't work. I would like something that works every time, so free_port() would be a good fit if it would work.


Solution

  • I came across the same problem. It isn't a problem in the RSelenium package, it's in the netstat. I've typed netstat –s –p tcp in my command prompt and saw that the statistics were coming out in my local language. Until developers resolve this, you've to change your OS language to English.