4

I'm trying to execute code on R with the package RSelenium to do some webscraping, but I'm blocked at the very first step. After loading the library, I try to run this line of code:

rmDr <- rsDriver(browser = "chrome", chromever = 'latest')

But the console returns :

Error in java_check() : PATH to JAVA not found. Please check JAVA is installed.

Java is indeed installed on my computer, but I'm guessing the path isn't the one the package is waiting for. Does someone know where I could modify the path in the RSelenium package code so that I can run this? To be noted, I'm working on a company computer and so I don't have every admin rights.

Thanks for your help!

Anas Abu Farraj
  • 1,540
  • 4
  • 23
  • 31
dgtrot
  • 41
  • 1
  • 1
  • 4
  • 1
    Docker is the best option (and I believe the only supported option currently). If you can't get that installed for some reason Java errors can often be solved by making sure you have the correct version of Java installed. There are lots of different versions. Your Java also has to match your Selenium and R versions. So if you have 64-bit R then you need to install 64-bit Java and 64-bit Selenium. It is a huge pain to find the 64-bit version of Java because it keeps trying to give you links to the 32-bit version. – Adam Sampson Mar 11 '19 at 13:25

3 Answers3

1

You can use method "remoteDriver()" instead of "rsDriver()". I checked it today with the last stable version of selenium driver (3.141.59) and it works perfectly.

Here's the code sample:

library(RSelenium)
driver <- remoteDriver()
driver$open()
driver$navigate("https://www.google.com/")
Jenya Pu
  • 733
  • 1
  • 7
  • 13
0

The best way to use RSelenium is to go through Docker. I used this tutorial, https://rpubs.com/johndharrison/RSelenium-Docker, not a long time ago, all went smooth.

Besides, you need a debugger, you can not scrape without it. That's why this tutorial is a good idea.

Let know if anything goes wrong.

Mez13
  • 168
  • 1
  • 3
  • 13
0

Just got the same error, installed the latest Java Development Kit (JDK), restarted a machine and everything worked ok.