How to start chrome from R console with ChromeDriver and RSelenium? - r

I am trying to open chrome from R console using command
> remDr <- remoteDriver(remoteServerAddr = "localhost" , port = 4444 , browserName = "chrome")
> remDr$open()
the versions are all latest.
chrome - 55
chromedriver - 2.27
selenium standalone server - 3.0.1
I am able to connect to remote server with following error message but it doesn't open the browser.
$message
[1] "unknown error: Chrome failed to start: exited abnormally\n (Driver info: chromedriver=2.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320),platform=Linux 3.19.0-64-generic x86_64)"
but when i try to navigate, it throws following error,
> remDr <- remoteDriver(remoteServerAddr = "localhost" , port = 4444 , browserName = "chrome")
> remDr$open()
[1] "Connecting to remote server"
$webdriver.remote.sessionid
[1] "17e6e349-9a67-4423-a817-1798a3e60933"
$locationContextEnabled
[1] TRUE
$webStorageEnabled
[1] TRUE
$takesScreenshot
[1] TRUE
$javascriptEnabled
[1] TRUE
$message
[1] "unknown error: Chrome failed to start: exited abnormally\n (Driver info: chromedriver=2.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320),platform=Linux 3.19.0-64-generic x86_64)"
$hasTouchScreen
[1] TRUE
$platform
[1] "ANY"
$cssSelectorsEnabled
[1] TRUE
$id
[1] "17e6e349-9a67-4423-a817-1798a3e60933"
> remDr$navigate(url)
Selenium message:no such session
(Driver info: chromedriver=2.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320),platform=Linux 3.19.0-64-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 38 milliseconds
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:48:19 -0700'
System info: host: 'akshay-300E4Z-300E5Z-300E7Z', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.19.0-64-generic', java.version: '1.8.0_121'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{message=unknown error: Chrome failed to start: exited abnormally
(Driver info: chromedriver=2.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320),platform=Linux 3.19.0-64-generic x86_64), platform=ANY}]
Session ID: 31de4b0c481e4d0f4fae80ad2920f5c3
Error: Summary: NoSuchDriver
Detail: A session is either terminated or not started
class: org.openqa.selenium.NoSuchSessionException
Further Details: run errorDetails method
selenium server logs at server start :-
$ java -jar -Dwebdriver.chrome.driver=/home/hdpusr/ChromeDriver/chromedriver selenium-server-standalone-3.0.1.jar
19:24:09.727 INFO - Selenium build info: version: '3.0.1', revision: '1969d75'
19:24:09.728 INFO - Launching a standalone Selenium Server
2017-01-24 19:24:09.747:INFO::main: Logging initialized #299ms
19:24:09.808 INFO - Driver provider org.openqa.selenium.ie.InternetExplorerDriver registration is skipped:
registration capabilities Capabilities [{ensureCleanSession=true, browserName=internet explorer, version=, platform=WINDOWS}] does not match the current platform LINUX
19:24:09.808 INFO - Driver provider org.openqa.selenium.edge.EdgeDriver registration is skipped:
registration capabilities Capabilities [{browserName=MicrosoftEdge, version=, platform=WINDOWS}] does not match the current platform LINUX
19:24:09.809 INFO - Driver class not found: com.opera.core.systems.OperaDriver
19:24:09.809 INFO - Driver provider com.opera.core.systems.OperaDriver registration is skipped:
Unable to create new instances on this machine.
19:24:09.809 INFO - Driver class not found: com.opera.core.systems.OperaDriver
19:24:09.809 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered
19:24:09.810 INFO - Driver provider org.openqa.selenium.safari.SafariDriver registration is skipped:
registration capabilities Capabilities [{browserName=safari, version=, platform=MAC}] does not match the current platform LINUX
2017-01-24 19:24:09.853:INFO:osjs.Server:main: jetty-9.2.15.v20160210
2017-01-24 19:24:09.882:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler#6d8a00e3{/,null,AVAILABLE}
2017-01-24 19:24:09.900:INFO:osjs.ServerConnector:main: Started ServerConnector#4f933fd1{HTTP/1.1}{0.0.0.0:4444}
2017-01-24 19:24:09.900:INFO:osjs.Server:main: Started #452ms
19:24:09.900 INFO - Selenium Server is up and running
the following is the selenium server logs when i run
remDr$open()
server logs :--
19:24:28.515 INFO - SessionCleaner initialized with insideBrowserTimeout 0 and clientGoneTimeout 1800000 polling every 180000
19:24:28.548 INFO - Executing: [new session: Capabilities [{nativeEvents=true, browserName=chrome, javascriptEnabled=true, version=, platform=ANY}]])
19:24:28.566 INFO - Creating a new session for Capabilities [{nativeEvents=true, browserName=chrome, javascriptEnabled=true, version=, platform=ANY}]
Starting ChromeDriver 2.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320) on port 20845
Only local connections are allowed.
19:24:28.990 INFO - Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
19:25:29.106 INFO - Detected dialect: OSS
19:25:29.154 INFO - Done: [new session: Capabilities [{nativeEvents=true, browserName=chrome, javascriptEnabled=true, version=, platform=ANY}]]
the following is the selenium server logs when i run
remDr$navigate(url)
server logs :--
20:33:42.918 INFO - Executing: [get: https://www.goodreads.com/book/show/18619684-the-time-traveler-s-wife#other_reviews])
No protocol specified
20:33:42.961 WARN - Exception thrown
org.openqa.selenium.NoSuchSessionException: no such session
(Driver info: chromedriver=2.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320),platform=Linux 3.19.0-64-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 16 milliseconds
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:48:19 -0700'
System info: host: 'akshay-300E4Z-300E5Z-300E7Z', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.19.0-64-generic', java.version: '1.8.0_121'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{message=unknown error: Chrome failed to start: exited abnormally
(Driver info: chromedriver=2.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320),platform=Linux 3.19.0-64-generic x86_64), platform=ANY}]
Session ID: e19869d41d81d1bbc51432cf08bec577
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:216)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:168)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:635)
at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:322)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.openqa.selenium.support.events.EventFiringWebDriver$2.invoke(EventFiringWebDriver.java:103)
at com.sun.proxy.$Proxy4.get(Unknown Source)
at org.openqa.selenium.support.events.EventFiringWebDriver.get(EventFiringWebDriver.java:162)
at org.openqa.selenium.remote.server.handler.ChangeUrl.call(ChangeUrl.java:40)
at org.openqa.selenium.remote.server.handler.ChangeUrl.call(ChangeUrl.java:25)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:176)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
20:33:42.967 WARN - Exception: no such session
(Driver info: chromedriver=2.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320),platform=Linux 3.19.0-64-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 16 milliseconds
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:48:19 -0700'
System info: host: 'akshay-300E4Z-300E5Z-300E7Z', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.19.0-64-generic', java.version: '1.8.0_121'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{message=unknown error: Chrome failed to start: exited abnormally
(Driver info: chromedriver=2.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320),platform=Linux 3.19.0-64-generic x86_64), platform=ANY}]
Session ID: e19869d41d81d1bbc51432cf08bec577
I also tried running selenium server using rsDriver but didn't made any difference, following is the rsDriver result
> rD <- rsDriver(port = 4567L, browser = c("chrome", "firefox", "phantomjs", "internet explorer"), version = "latest", chromever = "latest", geckover = "latest", iedrver = NULL, phantomver = NULL, verbose = TRUE, check = TRUE)
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
[1] "Connecting to remote server"
$webdriver.remote.sessionid
[1] "83941a25-4d50-426f-a006-2f056462f2b0"
$locationContextEnabled
[1] TRUE
$webStorageEnabled
[1] TRUE
$takesScreenshot
[1] TRUE
$javascriptEnabled
[1] TRUE
$message
[1] "unknown error: Chrome failed to start: exited abnormally\n (Driver info: chromedriver=2.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320),platform=Linux 3.19.0-64-generic x86_64)"
$hasTouchScreen
[1] TRUE
$platform
[1] "ANY"
$cssSelectorsEnabled
[1] TRUE
$id
[1] "83941a25-4d50-426f-a006-2f056462f2b0"
please someone assist me here.
Thanks

There seems to be an issue with chrome/chromedriver/selenium server. You will need verbose logging to check in more detail:
library(wdman)
library(RSelenium)
selServ <- selenium(jvmargs = c("-Dwebdriver.chrome.verboseLogging=true"))
remDr <- remoteDriver(port = 4567L, browserName = "chrome")
remDr$open()
selServ$log()
or if you prefer running seperately in the terminal start a selenium server as follows:
java -Dwebdriver.chrome.verboseLogging=true -Dwebdriver.chrome.driver=/home/hdpusr/ChromeDriver/chromedr‌​‌​iver -jar selenium-server-standalone-3.0.1.jar -port 4444
You can then file an issue with https://bugs.chromium.org/p/chromedriver/issues/list if the problem is not apparent.

Related

Rselenium driver error : driver.version: unknown, SessionNotCreatedException

It's been a week struggling with this. I've checked every version of chrome, chrome driver, geckodriver, Selenoum.jar, even R. I also replaced a number of rselenium folders in C drive.
Why R cannot sense the Chromedriver and returns SessionNotCreatedException error?
How can I solve this? I'm really desperate cause this is a part of my final assignment for uni,
and I cannot even start it.
I just want to go with Chrome, not switching to Mozila's Firefox.
OS : Windows 11
R version : 4.1.3
IDE : Rstudio
Chrome : 107.0.5304.107
geckodriver : geckodriver-v0.31.0-win64
chromedrvier : 107.0.5304.62
Selenium : selenium-server-standalone-4.0.0-alpha-1
JAVA : java version "17.0.4.1"
R code ↓
library(rvest)
library(dplyr)
library(httr)
library(RSelenium)
remDr = remoteDriver(
remoteServerAddr="localhost",
port=4445L,
browserName="chrome")
remDr$open()
R error message ↓
Selenium message:Unable to create new service: ChromeDriverService
Build info: version: '4.0.0-alpha-1', revision: 'd1d3728cae', time: '2019-04-24T16:15:24'
System info: host: 'JIMMMMM', ip: 'xxx.xxx.x.x', os.name: 'Windows 11', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.4.1'
Driver info: driver.version: unknown
Error: Summary: SessionNotCreatedException
Detail: A new session could not be created.
Further Details: run errorDetails method
cmd code ↓
C:\Windows\System32>cd C:\r-selenium
C:\r-selenium>java -Dwebdriver.gecko.driver="geckodriver.exe" -jar selenium-server-standalone-4.0.0-alpha-1.jar -port 4445
15:50:22.250 INFO [GridLauncherV3.parse] - Selenium server version: 4.0.0-alpha-1, revision: d1d3728cae
15:50:22.384 INFO [GridLauncherV3.lambda$buildLaunchers$3] - Launching a standalone Selenium Server on port 4445
15:50:22.816 INFO [WebDriverServlet.<init>] - Initialising WebDriverServlet
15:50:23.195 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 4445
15:50:35.377 INFO [ActiveSessionFactory.apply] - Capabilities are: {
"browserName": "chrome",
"javascriptEnabled": true,
"nativeEvents": true,
"version": ""
}
15:50:35.387 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
15:50:40.294 INFO [ActiveSessionFactory.apply] - Capabilities are: {
"browserName": "chrome",
"javascriptEnabled": true,
"nativeEvents": true,
"version": ""
}
15:50:40.297 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
Checked versions of every programm needed.
Checked binman::list_versions("chromedriver") to match the versions of Chrome driver and Chrome.
Reinstalled rsellenium library, Geckodriver, Chromedriver, Selenium.
Problem solved. It was all about directories...
I set my working directory as C:\r-selenium, but chromedriver and gecko were C:\r-selenium\chromedriver_win32,
C:\r-selenium\geckodriver-v0.17.0-win64 for each.

R - Selenium endlessly loads webpage

I've been successfully running a script daily for a while, but now it seems to be throwing a timeout error.
chromever = "96.0.4664.45"
rD <- rsDriver(browser="chrome", port= free_port(), chromever = chromever)
remDr <- rD[["client"]]
remDr$navigate("https://www.theweathernetwork.com/ca/14-day-weather-trend/british-columbia/coquitlam")
pageinfo <- read_html(remDr$getPageSource()[[1]])
precipitation <- pageinfo %>% html_nodes(".wxCell .wxObs") %>% html_text()
On the navigate line, the webpage endlessly loads, eventually throwing the following error:
Selenium message:timeout: Timed out receiving message from renderer: 299.608
(Session info: chrome=96.0.4664.45)
Build info: version: '4.0.0-alpha-2', revision: 'f148142cf8', time: '2019-07-01T21:30:10'
System info: host: 'WSS-WEATHER', ip: '*my ip here*', os.name: 'Windows Server 2016', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_291'
Driver info: driver.version: unknown
Error: Summary: Timeout
Detail: An operation did not complete before its timeout expired.
class: org.openqa.selenium.TimeoutException
Further Details: run errorDetails method
Chrome hasn't updated or anything, so I'm not sure what may have caused this to start happening seemingly out of the blue. Any ideas?

RSelenium cannot connect to Chrome

I am setting up Selenium in R
library(RSelenium)
rD <- RSelenium::rsDriver(browser="chrome")
When i run rsDriver(), it brought up chrome and gave the following errors
[1] "Connecting to remote server"
Selenium message:unknown error: unable to discover open pages
(Driver info: chromedriver=71.0.3578.33 (269aa0e3f0db08097f0fe231c7e6be200b6939f7),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 60.99 seconds
Build info: version: '3.141.5', revision: 'd54ebd709a', time: '2018-11-06T11:58:47'
System info: host: 'ELI-T460', ip: '172.xx.xx.xx', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_191'
Driver info: driver.version: unknown
Could not open chrome browser.
Client error message:
Summary: UnknownError
Detail: An unknown server-side error occurred while processing the command.
Further Details: run errorDetails method
Check server log for further details.
I have tried to run with older version of chromedriver and it gave the same error.

R error "Selenium message:Unable to create new service: ChromeDriverService"

Hi I'm trying to use RSelenium package in R on Windows 10.
Run command in cmd
java -Dwebdriver.chrome.driver="D:\Selenium\chromedriver.exe"
java -jar D:\Selenium\selenium-server-standalone-3.11.0.jar
and run code in R
remDr <- remoteDriver(browserName = "chrome", remoteServerAddr = "localhost", port = 4444L)
remDr$open()
But I get this following error
[1] "Connecting to remote server"
Selenium message:Unable to create new service: ChromeDriverService
Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:33:15.31Z'
System info: host: '*****', ip: '*****', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_144'
Driver info: driver.version: unknown
Error: Summary: SessionNotCreatedException
Detail: A new session could not be created.
Further Details: run errorDetails method
I downloaded Chrome(V66),The Chrome Webdriver(2.37),The Selenium Stand Alone Driver(3.11.0),all these are new version ,updated lately.
But I still get that error.Could someone please explain to me why?
issue solved.Command in cmd should be like the following code
java -Dwebdriver.chrome.driver="D:\Selenium\chromedriver.exe" -jar D:\Selenium\selenium-server-standalone-3.11.0.jar
I also got this very same issue- which got resolved by including -'chromeDriver.exe' path in command used for registering node.
like- >java -Dwebdriver.chrome.driver=C:\chromedriver_win32\chromedriver.exe -jar selenium-server-standalone-3.12.0.jar -role node -hub http://XX.XXX.XX:4444/grid/register

RSelenium error when connecting to server using Internet Explorer in windows

I try to use the RSelenium in windows with IE as browser as it seems there are some discrepancies with other browsers, and need some fixing with the newer versions.
I do as previously instructed in SO answers:
library(RSelenium)
startServer()
remDr <- remoteDriver(browser="internet explorer")
remDr$open()
remDr$open()
[1] "Connecting to remote server"
Selenium message:Unable to create new remote session. desired capabilities = Capabilities [{nativeEvents=true, browserName=internet explorer, javascriptEnabled=true, version=, platform=ANY}], required capabilities = Capabilities [{}]
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:48:19 -0700'
System info: host: 'CL5065F329EBF2', ip: '130.115.158.36', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_91'
Driver info: driver.version: InternetExplorerDriver
Error: Summary: SessionNotCreatedException
Detail: A new session could not be created.
class: org.openqa.selenium.SessionNotCreatedException
Further Details: run errorDetails method
Also when starting server or checking for servers I receive errors regarding deprecated use of the function.
For example:
startServer()
Warning message:
startServer 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")

Resources