facing issue in using a code about Rselenium

Hi
I am new to R.
I am trying to follow a tutorial about RSelenium.
I have installed Java in my machine.
But I am not able to run this code.

rs_driver_object <- rsDriver(
browser = c('chrome'),
version = '110.0.5481.30',
chromever = '110.0.5481.30',
verbose = FALSE,
port = free_port()
)

============
this error comes
Error in selenium_ver(selplat, version) :
version requested doesn't match versions available = 3.141.59,4.0.0-alpha-1,4.0.0-alpha-2
=============

can anyone guide me, what am I doing wrong?

Hi @Wajeehaijaz93 , you need check the specific version in Chrome.

Open your Chrome browser and verify de version, next put the correct version in:

rs_driver_object <- rsDriver(
browser = c('chrome'),
version = '110.0.5481.30',
chromever = '110.0.5481.30', # put your current version here
verbose = FALSE,
port = free_port()
)

Other way is try connect to java . jar

1 Like

Thank you for your response @M_AcostaCH, Noted.

Hello to both of you @M_AcostaCH and @Wajeehaijaz93 ! I'm sorry to suddenly drop in, but I'm experiencing a similar problem and found this post. Unfortunately, I can't seem to solve my issue the error messages I get keep changing. I'm a complete layperson myself when it comes to R, I'm just trying to run a script I received in Rstudio.
The script uses rselenium to scrape Goodreads reviews via Chrome. It gets stuck at the end of this piece of code:

library(rJava)        # Required to use RSelenium
library(data.table)   # Required for rbindlist
library(dplyr)        # Required to use the pipes %>% and some table manipulation commands
library(magrittr)     # Required to use the pipes %>%
library(rvest)        # Required for read_html
library(RSelenium)    # Required for webscraping with javascript
library(lubridate)    # Required to scrape the correct dates
library(stringr)      # Required to cut off any leading or trailing whitespace from text
library(purrr)

#Paste the GoodReads Url
url <- "https://www.goodreads.com/book/show/96290.Die_unendliche_Geschichte"

#Set your browser settings 
rD <- rsDriver(port = 4444L, browser = "chrome", chromever = "110.0.5481.77")
remDr <- rD[["client"]]
remDr$setTimeout(type = "implicit", 2000)
remDr$navigate(url)

The two errors I keep getting are:

checking Selenium Server versions:
BEGIN: PREDOWNLOAD
BEGIN: DOWNLOAD
BEGIN: POSTDOWNLOAD
Error in selenium_ver(selplat, version) : 
  version requested doesnt match versions available = 3.141.59,4.0.0-alpha-1,4.0.0-alpha-2

and this one:

Could not open chrome browser.
Client error message:
Undefined error in httr call. httr output: Failed to connect to localhost port 4444: Connection refused
Check server log for further details.
Warning message:
In rsDriver(port = 4444L, browser = "chrome", chromever = "110.0.5481.77") :
  Could not determine server status.

II have followed your advice, @M_AcostaCH , and have checked my Chrome version, but it is correct. I've also tried to chose another port or to just leave it out, but that does not solve the problem either. I was wondering whether you might be so kind as to give me some advice on how to solve this? Do you think connecting to java.jar could help here? And how do you do that?

Thank you for your help!

Im make the conection in this form with selenium-server-standalone-3.2.0.jar

library(RSelenium)

# put .jar and chrome driver in the same folder
# open cmd for set the drivers folders.
# run .jar file by cmd
# java -jar selenium-server-standalone-3.2.0.jar -port 4444

# Make conection--------------------------------------------------
remDr <- remoteDriver(remoteServerAddr = "localhost", port = 4444, browserName = "chrome")  
remDr$open()
Sys.sleep(5)
remDr$navigate(url = "https://www.goodreads.com/book/show/96290.Die_unendliche_Geschichte")

# My chrome version is 110.0.5481.178.
# Im download chromer driver  110.0.5481.77 of this list:  https://chromedriver.chromium.org/downloads

First of all thank you very much for replying so quickly! I really appreciate it!
Where can I find/download this selenium-server-standalone-3.2.0.jar and how do I run it via cmd? In this case, do I have to run the script from the same folder the chromedriver and jar-file are in?

Download the drivers:
https://drive.google.com/drive/folders/1JEvLqiPgn2fwyg8ExQou7SkyQgMRvSk0?usp=sharing

  1. Download and install.
  2. Get the Chrome driver according with your Chrome browser version.
  3. Put in the same folder Chrome driver and jre-8u231-windows-x64
  4. Set this folder with cmd
    image

An easy form is when you stay in the folder, delete the path and put cmd. This open automatic cmd in this folder. Next copy and paste thisjava -jar selenium-server-standalone-3.2.0.jar -port 4444 and press enter.

If all run well, you can connect to Selenium server

  1. Run the script: if you want could get the script in the same folder but is not a rule.
    Im get my scripts in other folders.
library(RSelenium)
remDr <- remoteDriver(remoteServerAddr = "localhost", port = 4444, browserName = "chrome") #very important check the correct Chrome driver for avoid
remDr$open() # this open new windows
Sys.sleep(5)
remDr$navigate(url = "https://www.goodreads.com/book/show/96290.Die_unendliche_Geschichte")


This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.