I have a cod.
JavaScript
x
19
19
1
@pytest.fixture(scope="function")
2
def browser():
3
selenium_grid_url = os.getenv('SELENIUM_HOST', "not_found") + "/wd/hub"
4
chrome_options = webdriver.ChromeOptions()
5
chrome_options.add_experimental_option('prefs', {'intl.accept_languages': 'ru-RU',
6
'download.default_directory': f'{directory}',
7
"download.prompt_for_download": False,
8
"download.directory_upgrade": True,
9
"safebrowsing.enabled": True
10
}
11
)
12
print(f"nStart Chrome browser.. {selenium_grid_url}")
13
capabilities = DesiredCapabilities.CHROME
14
browser = webdriver.Remote(desired_capabilities=capabilities, command_executor=selenium_grid_url,
15
options=chrome_options)
16
yield browser
17
print("nClose Chrome..")
18
browser.quit()
19
I have a docker + python + pytest + selenium + Chrome + selenium host and prefs But it doesn’t work. I want save to file without dialog window. But test don`t save files. How can I understand the reason? And… Downloading files works on Windows, but not docker on linux. P.S I have this path in docker env for chrome download and python DOWNLOAD_FOLDER=/app/download_files FOLDER_FOR_TEST_FILES=/app/test_files
My cod for check files
JavaScript
1
4
1
new_list_download_files = next(os.walk(f'{directory}'))[2]
2
first_doc = new_list_download_files[0]
3
second_doc = new_list_download_files[1]
4
Dockerfile
JavaScript
1
14
14
1
FROM python:3.8.12-buster
2
3
ENV PYTHONUNBUFFERED 1
4
5
ARG REQUIREMENTS=${REQUIREMENTS:-requirements.txt}
6
COPY ./${REQUIREMENTS} /requirements.txt
7
RUN pip install -r requirements.txt
8
9
RUN mkdir /app
10
COPY . /app
11
WORKDIR /app
12
13
ENTRYPOINT ["python"]
14
Advertisement
Answer
After 5 days. In the end, all you had to do was use docker-volumes. In docker-compose.yml
JavaScript
1
6
1
volumes:
2
data-volume:
3
download-volume:
4
external: true
5
name: selenium_downloads
6