I have a test that need to download file from a web by clicking on a button.
Test is able to pass when in non-headless mode.
However when I run it in headless it fails with timeout to download file.
Here are some details:
- Selenide version: 5.25.0
- Chrome Driver version: 111.0.5563.64
My configurations:
- non-headless run:
Configuration.timeout = 20000;
Configuration.fileDownload = FOLDER;
- headless run:
Configuration.headless = true;
Configuration.timeout = 20000;
Configuration.fileDownload = FOLDER;
Other options are as default, like downloads folder build/downloads
and rest of them.
My Selenide code to download file:
@SneakyThrows
public String downloadFile() {
return downloadButton.download(10000, withExtension("pdf")).getAbsolutePath();
}
The button element itself:
<button class="MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedSecondary" tabindex="0" type="button" test-id="download-button">
<span class="MuiButton-label">Download</span>
<span class="MuiTouchRipple-root"></span>
</button>
Logs:
- non-headless:
13:20:09.959 INFO com.codeborne.selenide.impl.DownloadFileToFolder - Downloaded 1 files:
#1 {root}\build\downloads\1678792759151_10256_1\109fc116-cc8b-42ba-9d7b-20733276bf64.pdf
- headless:
13:07:19.760 INFO com.codeborne.selenide.impl.DownloadFileToFolder - Downloaded 0 files:
13:07:19.778 INFO com.codeborne.selenide.impl.WindowsCloser - File has been opened in a new window, let's close 1 new windows
13:07:19.778 INFO com.codeborne.selenide.impl.WindowsCloser - Let's close B0C0F608D49BC5C008986B2B7AB210C5
I've tried all of the solutions described in similar topics with adding a lot of different combinations of chrome options but no luck.
Any help appreciated!