[英]Download files without dialog window selenium
I have a cod.我有一条鳕鱼。
@pytest.fixture(scope="function")
def browser():
selenium_grid_url = os.getenv('SELENIUM_HOST', "not_found") + "/wd/hub"
chrome_options = webdriver.ChromeOptions()
chrome_options.add_experimental_option('prefs', {'intl.accept_languages': 'ru-RU',
'download.default_directory': f'{directory}',
"download.prompt_for_download": False,
"download.directory_upgrade": True,
"safebrowsing.enabled": True
}
)
print(f"\nStart Chrome browser.. {selenium_grid_url}")
capabilities = DesiredCapabilities.CHROME
browser = webdriver.Remote(desired_capabilities=capabilities, command_executor=selenium_grid_url,
options=chrome_options)
yield browser
print("\nClose Chrome..")
browser.quit()
I have a docker + python + pytest + selenium + Chrome + selenium host and prefs But it doesn't work. 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.
我想在没有对话框 window 的情况下保存到文件。 But test don`t save files.
但测试不保存文件。 How can I understand the reason?
我怎样才能理解原因? And... Downloading files works on Windows, but not docker on linux.
并且...下载文件适用于 Windows,但不适用于 linux 的 docker。 PS I have this path in docker env for chrome download and python DOWNLOAD_FOLDER=/app/download_files FOLDER_FOR_TEST_FILES=/app/test_files
PS 我在 docker 环境中有这个路径用于 chrome 下载和 python DOWNLOAD_FOLDER=/app/download_files FOLDER_FOR_TEST_FILES=/app/test_files
My cod for check files我的检查文件的鳕鱼
new_list_download_files = next(os.walk(f'{directory}'))[2]
first_doc = new_list_download_files[0]
second_doc = new_list_download_files[1]
Dockerfile Dockerfile
FROM python:3.8.12-buster
ENV PYTHONUNBUFFERED 1
ARG REQUIREMENTS=${REQUIREMENTS:-requirements.txt}
COPY ./${REQUIREMENTS} /requirements.txt
RUN pip install -r requirements.txt
RUN mkdir /app
COPY . /app
WORKDIR /app
ENTRYPOINT ["python"]
After 5 days. 5天后。 In the end, all you had to do was use docker-volumes.
最后,您所要做的就是使用 docker-volumes。 In docker-compose.yml
在 docker-compose.yml
volumes:
data-volume:
download-volume:
external: true
name: selenium_downloads
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.