[Python] When running playwright in docker.Error:BrowserType.launch: Executable doesn't exist...

Discussão em 'Python' iniciado por Stack, Setembro 25, 2024.

  1. Stack

    Stack Membro Participativo

    I created a Dockerfile with this content

    FROM python:3.11-slim

    # Install requirements
    RUN apt-get update && apt-get install -y wget tar openjdk-17-jre
    RUN apt-get update && apt-get install gcc libsnmp-dev iputils-ping -y \
    && pip install --upgrade pip \
    && apt-get -y install curl \
    && apt-get clean


    # Install allure
    RUN wget --no-check-certificate https://github.com/allure-framework/allure2/releases/download/2.30.0/allure-2.30.0.tgz && \
    tar -zxvf allure-2.30.0.tgz -C /opt/ && \
    ln -s /opt/allure-2.30.0/bin/allure /usr/bin/allure && \
    rm allure-2.30.0.tgz

    # Create workdir
    WORKDIR /usr/workspace

    # Copy the dependencies file to the working directory
    COPY ./requirements.txt /usr/workspace

    # Install Python dependencies
    RUN pip3 install -r requirements.txt

    # Install playwright
    RUN playwright install --with-deps chromium


    and I use docker-compose to run it.

    version: "3.7"

    services:
    tests:
    image: tests:v1
    build:
    context: .
    dockerfile: Dockerfile
    volumes:
    - ./:/usr/workspace
    command: /bin/sh -c 'python3 -m pytest -v -m $MARKS --alluredir=./allure-results --node_id="$NODE_ID"'
    working_dir: /usr/workspace
    user: "997:997"


    everything runs locally without problems, but when it runs in CI on gitlab-runner, an error occurs

    playwright._impl._errors.Error: BrowserType.launch: Executable doesn't exist at /.cache/ms-playwright/chromium-1134/chrome-linux/chrome


    chromium is installed in the installation logs

    Chromium 129.0.6668.29 (playwright build v1134) downloaded to /root/.cache/ms-playwright/chromium-1134


    I tried to install chromium in different ways, the result is the same, everything is fine locally, but when in gitlab-runner, there is always an error. Gitlab-runner itself is just a shell

    RUN playwright install chromium
    RUN playwright install --with-deps chromium
    RUN playwright install-deps chromium

    Continue reading...

Compartilhe esta Página