Seeking help on how to resolve the subject line error.
The many previous posts and solutions referenced here have already been reviewed/tried.
In the past this same error has been resolved by updating R, Rstudio.
The code, which has worked for years and as recently as few days ago:
library(chromote) # to get the chrome version
library(netstat) # to dynamically change ports
library(RSelenium) # to run Selenium
b <- ChromoteSession$new()
browser_version <- b$Browser$getVersion()$product
browser_version<-gsub(".*/","",browser_version)
realVersion <- substr(browser_version,1,3)
chromeVersions <- binman::list_versions("chromedriver")
chromeVersions <- chromeVersions$win32
realChromeVer <-chromeVersions[which(substr(chromeVersions,1,3)==realVersion)]
driver <- rsDriver(browser = 'chrome', port = free_port(random = TRUE), chromever = realChromeVer[1], verbose = F)
remdr <- driver[['client']]
remdr$maxWindowSize()
Error message:
Could not open chrome browser.
Client error message:
Undefined error in httr call. httr output: Failed to connect to localhost port 3918: Connection refused
Check server log for further details.
Warning message:
In rsDriver(browser = "chrome", port = free_port(random = TRUE), :
Could not determine server status.
Is there anyway to get this running with rsDriver?
I would be really thankful if someone could help me in this problem.
See the answers here https://stackoverflow.com/a/75176907/15363011 and here https://github.com/ropensci/RSelenium/issues/264
The issue is likely that the newest Chrome versions (109+) are creating a bug that is preventing wdman::selenium() from running. Did you try deleting the license file in the chrome driver paths set by RSDriver (via the wdman package)?
Related
I am trying (for the first time) to scrape content from a dynamic webpage, for which RSelenium appears to be the go-to. I cannot however get past the first step of calling rsDriver.
My code:
rdriver <- rsDriver(browser = "chrome",
port = free_port(),
chromever = "109.0.5414.25")
The rsDriver() function started throwing an error every time I tried to open it
[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 14415: Connection refused Check
server log for further details. Warning message: In rsDriver(browser =
"chrome", port = free_port(), chromever = "109.0.5414.25") : Could
not determine server status.`
Version:
R 4.2.2
Java(TM) SE Development Kit 19.0.2 (64 bit)
> binman::list_versions("chromedriver")
$win32
[1] "109.0.5414.25" "109.0.5414.74" "110.0.5481.30"
> binman::list_versions("seleniumserver")
$generic
[1] "3.141.59" "4.0.0-alpha-1" "4.0.0-alpha-2"`
Any recommendations are much appreciated.
I installed all the necessary programs from scratch.
I searched for help on the internet and couldn't find a solution
there is an outstanding issue with how the wdman package reads the latest versions of Chrome. This is causing issues for lots of users (examples here https://stackoverflow.com/a/75176907/15363011 and here https://github.com/ropensci/RSelenium/issues/264)
You can specify a version of Chrome before the issue took place and binman/wdman will download and start using it:
rdriver <- rsDriver(browser = "chrome",
port = free_port(),
chromever = "108.0.5359.71")
If you'd like to use the newest versions, the fix is to delete the LICENSE.chromedriver file found in the same directory as the driver. You can find out how to do that in the other issues that I linked. If you want to use the latest version of Chrome you will have to do this any time a new chrome driver is released.
I have been using RSelenium for years and have never had this issue. I recently updated my google chrome to the latest version available 110.0.5481.78. I am now getting the following error when I go to use rsDriver
require(RSelenium)
rD <- rsDriver(browser = "chrome",port = 9537L, chromever = "110.0.5481.77")
"> Could not open chrome browser.
> Client error message:
> Undefined error in httr call. httr output: Failed to connect to localhost port 9537: Connection refused
> Check server log for further details.
> Warning message:
> In rsDriver(browser = "chrome", port = 9537L, chromever = "110.0.5481.77") :
> Could not determine server status."
R Console
I have tried with different versions of chromever from binman::list_versions("chromedriver") as well as leaving rsDriver blank all together. In the past when chrome has updated it has been a very simple change to chromever and everything works perfectly. Not sure if or what has changed with this latest update.
Thanks in advance.
I just fixed this same problem by removing a file LICENSE.chromedriver as per this thread: https://github.com/ropensci/RSelenium/issues/264
Use
wdman::selenium(retcommand=T)
to find the file location of binman_chromedriver files.
Navigate to this file location, go to the driver version you're using and delete the LICENSE.chromedriver file. Mine worked immediately after this action, but note that I also tried downgading wdman version to 0.2.5 (I was on 0.2.6) first:
remotes::install_version('wdman',version = '0.2.5')
I'm not sure if it was both actions that fixed it or just the file delete!
Until recently, I was using RSelenium without any problem. When I try to connect to hostr rsDriver() to start a selenium server and browser, I get the following error message:
Could not open firefox browser.
Client error message:
Undefined error in httr call. httr output: Failed to connect to localhost port 5111: Connection refused
Check server log for further details.
Warning message:
In rsDriver(browser = "firefox", port = 5111L, verbose = F) :
Could not determine server status.
I have looked at some answers already proposed, like in this page. However, when I run the command,
> selServ <- wdman::selenium(verbose = FALSE)
> selServ$log()
I get the following error message:
$stderr
[1] "Error: Could not find or load main class c(-Dwebdriver.chrome.driver="C:\\\\Users\\\\user\\\\AppData\\\\Local\\\\binman\\\\binman_chromedriver\\\\win32\\\\109.0.5414.25.chromedriver.exe\","
$stdout
character(0)
I tried to reinstall Java, but without success.
Ok I just solved the issue. The issue was that RSelenium recognises the chromedriver even when using other browsers so when the driver is not compatible to your current chrome version, it would have an issue with rsDriver. In order to solve this, you can either input NULL next to chromever or older chrome driver version from C:\Users\NAME\AppData\Local\binman\binman_chromedriver\win32
rD <- rsDriver(port= sample(7600)[1], browser=c("firefox"), chromever = NULL)
rD <- rsDriver(port= sample(7600)[1], browser=c("firefox"), chromever = 108.0.5359.22)
I am trying to scrape some comments from a job feedback web site using RSelenium.
I am facing a following problem when I try to run this line of code:
library(RSelenium)
rs <- rsDriver(browser = "firefox", check = FALSE)
And then the problem pops up:
[1] "Connecting to remote server"
Could not open firefox 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.
Warning:
В rsDriver(browser = "firefox", check = FALSE) :
Could not determine server status.
The latest Java and Mozilla Firefox versions are installed onto my laptop. Also added the path to Java's bin in the Win system options. I have no clue why this problem occurs.
I've been learning R programming for the last few months and really enjoying the language. I wanted to start using it to automate a few things at work. However for the life of me no matter how much I Google or experiment I can't seem to start the browser.
I followed the steps from this article
https://www.r-bloggers.com/rselenium-a-wonderful-tool-for-web-scraping/
and got the server started from the command line. This is the code I ran in the console and the error message I'm getting.
> library(RSelenium)
> checkForServer()
Warning message:
checkForServer is deprecated.
Users in future can find the function in
file.path(find.package("RSelenium"), "example/serverUtils").
The sourcing/starting of a Selenium Server is a users responsiblity.
Options include manually starting a server see
vignette("RSelenium-basics", package = "RSelenium")
and running a docker container see
vignette("RSelenium-docker", package = "RSelenium")
I'm running on Windows 10 64-bit and have installed the latest Firefox.
Any help or pointers on this would be greatly appreciated.
Thanks,
Shan
Okay, I just went through this. So you can skip the whole Selenium Server entirely by just using phantomjs, which RSelenium can call directly.
Steps:
Download phantomjs for your platform here
Put this binary file in the system PATH or anywhere else you have access too from R
Now try this:
library(RSelenium)
pJS <- phantom(pjs_cmd = "<YOUR BINARY LOCATION>") # no arg if it's in PATH
Sys.sleep(5)
remDr <- remoteDriver(browserName = "phantomjs")
remDr$open(silent = T)
url <- "http://www.google.com"
remDr$navigate(url)
remDr$screenshot(display = TRUE)
NOTE: When I run this I get an error after the first step, but it still works and pulls up the page. Not sure why that happens.