1

I am currently using the following code where ${BASE_URL} is my system under test and ${BROWSER} value is set to chrome. I have followed the solution provided on the thread: click here

But somehow disabling the Chrome PDF Viewer is not working. I am still seeing PDFs are being opened in new tab instead of downloaded to local directory.

*** Settings ***
Documentation    Common setup and teardown steps
Library    SeleniumLibrary
Resource   UtilManager.robot

*** Keywords ***
Begin Test
    [Arguments]     ${BROWSER}      ${BASE_URL}

    @{workingDirs}      UtilManager.Get Current Working Directories

    ${chrome options}=    Evaluate    sys.modules['selenium.webdriver'].ChromeOptions()    sys, selenium.webdriver
    log     ${chrome_options}
    # list of plugins to disable. disabling PDF Viewer is necessary so that PDFs are saved rather than displayed
    ${disabled}    create list    Chrome PDF Viewer
    ${prefs}    create dictionary    download.default_directory=${workingDirs}[1]    plugins.plugins_disabled=${disabled}
    call method    ${chrome options}    add_experimental_option    prefs    ${prefs}
    create webdriver    ${BROWSER}    chrome_options=${chrome options}


    go to    ${BASE_URL}
    maximize browser window
Avik Datta
  • 23
  • 4
  • 1
    I am not sure about robot framework but if you are looking for plugins then it should help. https://stackoverflow.com/questions/69251242/selenium-java-how-to-download-a-pdf-and-save-with-a-different-name/69254982#69254982 – Nandan A Nov 03 '21 at 12:40
  • 1
    Thanks for your reply. I will try out adding a new option. `chromeOptionsMap.put("plugins.always_open_pdf_externally", true);` – Avik Datta Nov 03 '21 at 12:44
  • Update: not seeing any change after adding the above plugin option. Pdfs are still opening in a new tab. – Avik Datta Nov 03 '21 at 13:20
  • Have you added `plugins.plugins_disabled`? – Nandan A Nov 03 '21 at 13:22
  • 1
    In C# (instead of python) you need to add the the plugins.externally in the user profile. NOT in the options directly, but some map within the options map. For the code example, I'll comeback to you – Taco Verhagen Nov 03 '21 at 21:24
  • @NandanA - yes currently my code has both. – Avik Datta Nov 04 '21 at 14:14

0 Answers0