seleniumbase / SeleniumBase

📊 Python's all-in-one framework for web crawling, scraping, testing, and reporting. Supports pytest. UC Mode provides stealth. Includes many tools.
https://seleniumbase.io
MIT License
4.45k stars 908 forks source link

Dockerized SB with UC mode doesn't save file in downloaded_files dir #2868

Closed balovp closed 1 week ago

balovp commented 1 week ago

Hello. We had built docker image with seleniumbase. Seleniumbase runs scripts well, saves screenshots, but doesn't download files into downloaded_files folder. Could you help us?

requirements.txt

dockerfile:

FROM debian:bullseye-20240513

ARG ARGUMENTS

ARG USER_ID

ARG GRUP_ID

ARG OPTIONS

# WORKDIR /

COPY requirements.txt .

USER root

#============================
# Install Linux Dependencies
#============================
RUN apt update && apt install -y \
    software-properties-common \
    apt-transport-https \
    ca-certificates \
    libcairo2-dev \
    fonts-liberation \
    libasound2 \
    libatk-bridge2.0-0 \
    libatk1.0-0 \
    libatspi2.0-0 \
    libcups2 \
    libdbus-1-3 \
    libdrm2 \
    libgbm1 \
    libgtk-3-0 \
    libnspr4 \
    libnss3 \
    libwayland-client0 \
    libxcomposite1 \
    libxdamage1 \
    libxfixes3 \
    libxkbcommon0 \
    libxrandr2 \
    libu2f-udev \
    libvulkan1 \
    xdg-utils \
    dirmngr \
    gnupg2

#=================================
# Install Bash Command Line Tools
#=================================
RUN apt-get -qy --no-install-recommends install \
    curl \
    sudo \
    unzip \
    nano \
    wget \
    xvfb && \
    rm -rf /var/lib/apt/lists/*

#================
# Add GPG-keys
#================
RUN gpg --batch --keyserver hkp://keyserver.ubuntu.com --recv-keys E88979FB9B30ACF2 && \
    gpg --export --armor E88979FB9B30ACF2 | apt-key add - && \
    apt-get purge -y gnupg2 dirmngr && \
    rm -rf /var/lib/apt/lists/*

#================
# Install Chrome
#================
RUN curl -fSsL https://dl.google.com/linux/linux_signing_key.pub | gpg --dearmor | tee /usr/share/keyrings/google-chrome.gpg >> /dev/null && \
    echo deb [arch=amd64 signed-by=/usr/share/keyrings/google-chrome.gpg] http://dl.google.com/linux/chrome/deb/ stable main | tee /etc/apt/sources.list.d/google-chrome.list && \
    apt update && apt install -y google-chrome-stable

#================
# Install Python
#================
RUN apt update && apt install -y \
    python3-setuptools \
    python3-venv \
    python3-pip \
    python3-dev \
    python3 && \
    alias python=python3 && \
    echo "alias python=python3" >> ~/.bashrc

#===========================
# Configure Virtual Display
#===========================
RUN set -e && \
      echo "Starting X virtual framebuffer (Xvfb) in background..." && \
      Xvfb -ac :99 -screen 0 1280x1024x16 > /dev/null 2>&1 & \
      export DISPLAY=:99 && \
      exec "$@"

COPY SeleniumBase /SeleniumBase
COPY SeleniumBase/integrations/docker/docker-entrypoint.sh /
COPY SeleniumBase/integrations/docker/run_docker_test_in_chrome.sh /

RUN chmod +x *.sh && \
      python3 -m venv venv && \
      pip install --upgrade pip

RUN pip install -r requirements.txt && \
    pip install --upgrade pip setuptools wheel

ENV PYTHONPATH=/home/app/.local

ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["/bin/bash"]

testing script:

from seleniumbase import SB
import os

with SB(uc=True, headless2=True) as sb:
    sb.open("http://xcal1.vodafone.co.uk/")
    sb.uc_click('a[href="http://212.183.159.230/5MB.zip"]')
    sb.driver.sleep(30)
mdmintz commented 1 week ago

Duplicate of https://github.com/seleniumbase/SeleniumBase/discussions/2869