ashbythorpe / selenider

Concise, Lazy and Reliable Wrapper for 'chromote' and 'selenium'
https://ashbythorpe.github.io/selenider/
Other
32 stars 2 forks source link

Running in Docker #22

Closed rcepka closed 4 months ago

rcepka commented 4 months ago

Hello, I created an R script which uses Selenider to collect some information from the web. I want to run this script from a Docker container, but I am getting this error on the Docker start:

selenider installed
`google-chrome` and `chromium-browser` were not found. Try setting the `CHROMOTE_CHROME` environment variable to the executable of a Chromium-based browser, such as Google Chrome, Chromium or Brave or adding one of these executables to your PATH.
Error in initialize(...) : Invalid path to Chrome
Calls: selenider_session ... <Anonymous> -> initialize -> <Anonymous> -> initialize
Execution halted

Apparently, I am missing either Chromote or Selenium in my system. I prefer using Chromote over Selenium and attached as a Docker container, not installing it onto my server. Could you provide me some hints how to make it working, setup like this please?

Thank you very much.

ashbythorpe commented 4 months ago

From my memory, that error occurs when chromote::find_chrome() fails. This suggests that you have installed chromote successfully, but you don't actually have Google Chrome or Chromium installed (or if you do, chromote can't find it). I think that installing Chrome in your Docker image should fix this issue (I'm not super experienced with Docker, so I'm not sure exactly how you would do this).

kasimrafique commented 4 months ago

If your docker file is like your one in rstudio/chromote#157, try installing chrome in the image in one of the 2 following ways:

RUN apt-get install -y wget
RUN wget -q https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
RUN apt-get install -y ./google-chrome-stable_current_amd64.deb

from this thread

RUN curl -LO https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
RUN apt-get install -y ./google-chrome-stable_current_amd64.deb

or from here

Hopefully, chromote would be able to find chrome and the container will start up without an error :)

rcepka commented 4 months ago

@Doozy134 , Thank you for your hints, it works like a charm. I needed to add to my Dockerfile a line for OS updating otherwise I would be receiving errors about unmet dependencies; but this might be just my case determined by my particular base image. Thanks once again.

@ashbythorpe , many thanks to you too, you always respond with the best intention to help, also I understand that this type of request goes beyond the module support.

Closing as fixed.