PythonHeadlessChrome icon indicating copy to clipboard operation
PythonHeadlessChrome copied to clipboard

Not working for Mac

Open timothyshort opened this issue 7 years ago • 0 comments

I copied over as you have but I am having issues on my end. Downloading files with headed Chrome is fine, but can't get it with Chrome headless. I'm running Chrome 66 on MacOSX, Python 3, Selenium 3.11

#Initial settings

chrome_path = root_dir + "software/chromedriver"
chrome_profile = chrome_webdriver.Options()
profile = {
    'download.default_directory' : data_dir,
    "download.prompt_for_download": False,
    "download.directory_upgrade": True,
    'safebrowsing.enabled': False,
    'safebrowsing.disable_download_protection': True
    }    
chrome_profile.add_experimental_option('prefs', profile)
chrome_profile.add_argument("--headless")

And then...

#Once browser is launched, execute following command to "enable" headless downloading

browser.command_executor._commands["send_command"] = ("POST", '/session/$sessionId/chromium/send_command')
params = {'cmd': 'Page.setDownloadBehavior', 'params': {'behavior': 'allow', 'downloadPath': data_dir}}
command_result = browser.execute("send_command", params)
print("response from browser:")
for key in command_result:
    print("result:" + key + ":" + str(command_result[key]))

Program runs without errors, but cannot download as I was able to in headed mode. Anything different from Mac to Windows?

timothyshort avatar May 14 '18 15:05 timothyshort