1

I couldn't open Chrome with help Rselenium. When I am using Firefox all works fine. Already tried to install chromedriver for 77 (https://chromedriver.storage.googleapis.com/index.html?path=77.0.3865.10/) due to below error:

Selenium message:session not created: This version of ChromeDriver only supports Chrome version 77
Build info: version: '4.0.0-alpha-2', revision: 'f148142cf8', time: '2019-07-01T21:30:10'
System info: host: 'DESKTOP-L8K5E4H', ip: 'xxx', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_211'
Driver info: driver.version: unknown
remote stacktrace: Backtrace:

I followed steps included in post under link: How to open Google Chrome with RSelenium?

Code from link:

library("RSelenium")
startServer()
mybrowser <- remoteDriver(browserName = "chrome")
mybrowser$open()

My code:

library("RSelenium")
    rD <- rsDriver(port=4444L,browser="chrome")
    mybrowser <- remoteDriver(browserName = "chrome") 
    mybrowser$open()

Both works wrongly. I still receive error like at the beggining connected with wrong chromedriver version. I am looking for solutions to run app on chrome. My Google Chrome version 76.0.3809.132 (64 bits)

Geron
  • 85
  • 1
  • 7
  • Maybe this post can help you: https://stackoverflow.com/questions/45784165/rselenium-timeout-on-windows-7/45785848#45785848 – Marco Sandri Sep 03 '19 at 15:51
  • Hello, Thanks for the link, but still receive same error. Chrome opens, but close immediately itself.Is there some way to point out location to chromedriver? – Geron Sep 03 '19 at 16:07
  • Did you try to use the most recent chrome driver ? https://chromedriver.storage.googleapis.com/index.html?path=77.0.3865.40/ – Marco Sandri Sep 03 '19 at 17:37

1 Answers1

3

You can avoid such and similar issues with RSelenium by running the browser in a Docker container. Then you don't need any drivers and chances are higher that your code will work in the future. This is especially recommended when you use macOS. The operating system has obstacles in place to prevent remote control of a browser for security reasons.

  1. Download and install Docker.

  2. Pull a Docker image of Chrome by entering the following command in the Terminal.

     docker pull selenium/standalone-chrome -debug
    

    You should now see “standalone-chrome” under “Images” in Docker. On the image click “Run” to create a new container. Select “Optional Setting”, set the “Local Host” to 4445, and add a second port with “+”, setting it to 5899. Run it.

  3. For Web scraping it is often necessary to see how the browser behaves. To see inside a Docker container, download and install the VNC Viewer. Then launch the VNC Viewer and connect to “127.0.0.1:5899” while the Docker container is running. The password is “secret” by default.

  4. Install RSelenium and execute the following four lines. You can see whether it worked by looking inside the container with the VNC Viewer. You should see the website of your choice defined by "url", for example "https://www.qwant.com".

     library(RSelenium)
     remDr <- rsDriver(port=4445L)
     remDr$open()
     remDr$navigate(url)
    
fabioklr
  • 430
  • 1
  • 5
  • 13