Is it possible to use selenium in render?

Languege: python 3.10
Library: chromedriver-binary-auto==0.2.1

I want to run selenium on render.
I tried installing chrome with docker, but an error occurred.

code:
options = Options()
options.add_argument(“–headless”)
options.add_argument(“–disable-dev-shm-usage”)
options.add_argument(“–no-sandbox”)
self.driver = webdriver.Chrome(options=options) ← error

error message:
selenium.common.exceptions.WebDriverException: Message:
unknown error: Chrome failed to start: crashed.
(unknown error: DevTools ActivePort file doesn’t exist)

Is it possible to run selenium in render?
If possible, I would appreciate it if you could provide a simple example.

Hi there,

Thanks for reaching out.

If you’re running in Docker, you’re in control of the environment. A quick Google for the error you shared, “DevTools ActivePort file doesn’t exist”, brings up a StackOverflow post. There are some suggested solutions in there, seems it could be related to trying to run Chrome as root.

Alternatively, it might be possible to install Chrome on a Native Environment with a build script which includes something like this https://gist.github.com/BigAlRender/41f4c4d87df3e25770e3db8db728443e

Hope that helps

Alan

Hi al_ps,

Thank you for your reply.
I’ve tried many things, but haven’t found a solution yet.

I am currently trying to do something and would like to know if the following docker-compose.yml can be converted to render.yaml.

<docker-compose.yml>

version: "3"
services:
  selenium:
    image: selenium/standalone-chrome-debug
    ports:
      - 4444:4444
      - 5900:5900

Can this be converted?

thanks.

It would be very helpful if you would share the things you’ve tried and the issues that were raised to see where to offer assistance.

However, it feels like it should be as simple as put the image in a Dockerfile:

# Dockerfile.seleniumFROM selenium/standalone-chrome-debug:latest

Specify that Dockerfile from a Blueprint (creating it as a Private Service)

# render.yamlservices: type: pserv name: selenium-standalone-chrome-debug env: docker dockerfilePath: ./Dockerfile.selenium

Alan

I am trying to check with the below configuration.
It worked success in my local environment.

docker-compose.yml

version: "3"
services:
  selenium:
    image: selenium/standalone-chrome-debug
    ports:
      - 4444:4444
      - 5900:5900
  app:
    build: ./app
    volumes:
      - ./app:/app
    ports:
      - "8000:8000"
    tty: true

Dockerfile

FROM python:3.7
ENV PYTHONIOENCODING utf-8
WORKDIR /app
RUN pip install --upgrade pip
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
EXPOSE 8000
USER 1000
CMD [ "python", "./app.py" ]

python(app.py)

options = Options()
options.add_argument("--no-sandbox")
options.add_argument("--headless")
options.add_argument("--disable-dev-shm-usage")
self.driver = webdriver.Remote(
    command_executor='http://selenium:4444/wd/hub',
    desired_capabilities=DesiredCapabilities.CHROME.copy(),
    options=options
)

I’m thinking of migrating this configuration to Render.
I am thinking of converting to render.yaml because docker-compose.yml is not available.
Any method other than converting to render.yaml is fine.

Hi,

I provided an example of how you could use a Render Blueprint to deploy the selenium image you shared previously, if you want to expand that to include your Python Dockerfile the process would be much the same. The full Blueprint spec is available in the docs

If you run across any issues, feel free to raise them here or open a ticket, but we wouldn’t write your full render.yaml for you.

Kind regards

Alan

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.