I am trying to download an xls file using a link in Headless mode. The file is getting downloaded in head mode. Scenario:
- Need to click on a link
- There is no link that can get retrieved as href attribute is not present
- After clicking on the link, a new tab gets opened.
- Once the tab gets opened download starts.
- I am unable to switch to a tab in headless mode as it gets immediately closed.
Chrome options set:
$chromeoptions = ["--headless",
"--disable-gpu",
"--window-size=1920,1200",
"--ignore-certificate-errors",
"--disable-extensions",
"--no-sandbox",
"--disable-dev-shm-usage",
"--disable-popup-blocking"];
$preferences = array(
"download.prompt_for_download" => false,
'download.default_directory' => $this->downloadDirectoryPath,
"directory_upgrade" => true,
"credentials_enable_service" => false,
"Browser.setDownloadBehaviour" => array(
"behavior" => "allow",
"downloadPath" => $this->downloadDirectoryPath
),
"browser.helperApps.neverAsk.saveToDisk" => "application/vnd.ms-excel"
);
Selenium Version: 4.8.1 Chrome Driver version: 81.0.4044.138
Note: I can't upgrade to the latest Chrome version as we purposefully installed this version.
Tried setting Chrome options but nothing worked. Does anybody face the same problem with Selenium Chrome?