How can i use Page.setDownloadBehavior in chrome dev tools to pass on so that I can set the download behavior for headless chrome with the code below?
Create Chrome Browser
[Arguments] ${link_to_open}
${chrome_options}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver
${prefs}= Create Dictionary download.default_directory=${DOWNLOADS_DIR}
Call Method ${chrome options} add_argument headless
Call Method ${chrome options} add_argument disable-gpu
Selenium2Library.Go To ${link_to_open}
There appears to be a 'security feature' when trying to download a file using Chrome in headless mode. This is further discussed in the Chromium issue tracker. This pointed to the StackOverflow answer for Downloading with chrome headless and selenium. In this answer a Python example is given (GitHub) which converts easily to a Robot Framework Library:
headless_download.py
When downloading a file, the StackOverlow answer for Robot Framework Download File that fits this example perfectly. Adding the extra lines for headless mode, additional library and a working example:
headless_download.robot
So, in short: this answer was not possible without the contributions by others on Stack Overflow. If this provides you with a working solution, please follow the links to the other answers and upvote those answers as well.