I've setup some keywords to open Chrome with certain options/prefs. I have a Python keyword as follows:
def set_chrome_options(dldir):
""" Sets specific Chrome Options to pass to Robot. See in-line comments for more. """
options = webdriver.ChromeOptions()
options.add_argument("--start-maximized") # Starts the window maximized
options.add_argument("--disable-infobars") # Does not show the infobar about automated software running
options.add_experimental_option("prefs", {
"download.default_directory": dldir, # Sets download directory based on argument given
"download.prompt_for_download": False, # Sets downloads to NOT prompt, will save to above directory
"download.directory_upgrade": True # Needed to make the above 2 work correctly
})
options.add_experimental_option("useAutomationExtension", False) # Gets around the extension policy error pop up
return options
Open Chrome Browser
[Documentation] Open an instance of Chrome using options defined in our Python keyword 'Set Chrome Options'.
[Arguments] ${url} ${dldir}
${chrome_options}= Set Chrome Options ${dldir}
Create Webdriver Chrome chrome_options=${chrome_options}
Goto ${url}
This all works great, but when it tries to download PDF files from the site I'm testing, I get an error: