0

I try to save same files from site using selenium whith docker-compose. When i do .click() on link to downloads file, it mast saved in container /home/seluser/Downloads but when i try to mount values to save files in host: -./app/down:/home/seluser/Downloads
it only erases all in folder Downloads in selenium container and while the program is running no files appear in container /home/seluser/Downloads, but without definition volumes all files appear normally in conainer.

alex@alex-Aspire-E1-571G:~/documents/python/yahoo_script/app$ docker ps
CONTAINER ID   IMAGE                        COMMAND                  CREATED          STATUS          PORTS                                       NAMES
aebf66508644   yahoo_script_app             "sh -c 'python3 main…"   32 seconds ago   Up 28 seconds                                               yahoo_script_app_1
16ad4ae3ddb0   selenium/standalone-chrome   "/opt/bin/entry_poin…"   34 seconds ago   Up 31 seconds   0.0.0.0:4444->4444/tcp, :::4444->4444/tcp   yahoo_script_selenium_1
alex@alex-Aspire-E1-571G:~/documents/python/yahoo_script/app$ docker exec -it 16 /bin/sh
$ cd home/seluser/Downloads
$ ls
PD.csv  PINS.csv  ZUO.csv

My Dockerfile:

FROM python:3.8
ENV PYTHONUNBUFFERED 1
RUN pip install --upgrade pip
COPY ./requirements.txt /requirements.txt
RUN pip install -r /requirements.txt
COPY ./app /app
WORKDIR /app

My docker-compose.yml

version: "3"

services:
  selenium:
    image: selenium/standalone-chrome
    volumes:
      - ./app/down:/home/seluser/Downloads
    ports:
    - 4444:4444
    restart: always

  app:
    build:
      context: .
    volumes:
    - ./app:/app
    command: sh -c "python3 main.py"
    depends_on:
      - selenium

And code:

    options = webdriver.ChromeOptions()
    options.headless = True
    options.add_argument("--no-sandbox")
    options.add_argument('--disable-blink-features=AutomationControlled')
    prefs = {'download.default_directory': f'/home/seluser/Downloads',
             "directory_upgrade": True,
             "safebrowsing.enabled": True
             }
    options.add_experimental_option('prefs', prefs)
    capabilities = {
        "browserName": "chrome",
        "version": "90.0.4430.85",
        "platform": "LINUX"
    }
    driver = webdriver.Remote('http://selenium:4444/wd/hub', desired_capabilities=capabilities, options=options)

How can I have files from container to host?

  • I find answer in https://stackoverflow.com/questions/28868730/prompt-for-download-is-still-appearing-after-setting-false-in-prefs Main thing is what ```Aside from that, make sure directory exists and there are permissions to write into it.``` – Александр Илларионов May 31 '21 at 08:27

1 Answers1

-1

I find answer in Prompt_for_download is still appearing after setting false in prefs Main thing is what
Aside from that, make sure directory exists and there are permissions to write into it.