So I am working on a project where I have to download hundreds of report from web server of SSRS. I wrote a program in python using selenium.
The requirement is that the reports should be downloaded in background.
I tried to get to the URL which downloads the report in excel format using
driver.get(url)
and the file was downloaded.
Whenever I connect to the URL a window pops up asking for user id and password.
So to address this I added two lines of code in chrome_options.
Then the popup disappeared and the report was downloaded normally. But as soon as I add chrome_options(--headless) in the code the file is not downloaded only a console opens and it closes after a while
So what I am saying is that this code works
I cannot understand why this is happening. Can anyone explain to me why my code does not work in headless mode? Here's my full code (URL altered for privacy)
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from subprocess import CREATE_NO_WINDOW
import time
import datetime
import os
service = Service(executable_path=r'C:\Program Files\chromedriver_win32\chromedriver.exe')
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--headless=new")
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument("--disable-extensions")
chrome_options.add_argument("--auth-server-whitelist=*")
chrome_options.add_argument("--auth-negotiate-delegate-whitelist=*")
chrome_options.add_argument("--log-level=0")
service.creation_flags = CREATE_NO_WINDOW
print('starting download')
driver=webdriver.Chrome(service=service,options=chrome_options)
driver.get("http://10.1.2.69:99/ReportServer")
time.sleep(3)
print('file downloaded')
driver.quit()