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 =============
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()
)
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?
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?
Get the Chrome driver according with your Chrome browser version.
Put in the same folder Chrome driver and jre-8u231-windows-x64
Set this folder with cmd
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.
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")