# Disable Chrome PDF Viewer option not working in robot framework

**URL:** <https://forum.robotframework.org/t/disable-chrome-pdf-viewer-option-not-working-in-robot-framework/5332>\
**Category:** Robot Framework\
**Created:** [17 February 2023 13:07 UTC](https://forum.robotframework.org/t/disable-chrome-pdf-viewer-option-not-working-in-robot-framework/5332 "2023-02-17T13:07:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bk-user](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/bk-user/32/1446_2.png) [@bk-user](https://forum.robotframework.org/u/bk-user)\
**Post date:** [17 February 2023 13:07 UTC](https://forum.robotframework.org/t/disable-chrome-pdf-viewer-option-not-working-in-robot-framework/5332/1 "2023-02-17T13:07:29Z")

</div>

I have scenario when I click on Submit , it open the PDF in the window i.e. in chrome pdf viewer and I want to download that pdf in the download directory path instead opening that in the new page

 ![image](https://europe1.discourse-cdn.com/flex005/uploads/robotframework1/original/2X/3/3cbd3816454f7affe527d4fdf2a4c279702506a8.png)

I tried below code -

```
${download_directory} Join Path ${OUTPUT DIR} downloads
Set Global Variable ${download_directory_guid} downloads
Create Directory ${download_directory}
Set Global Variable ${download_directory}

${chrome options}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver
# 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 ${download\_directory} plugins.always\_open\_pdf\_externally ${True}

```
${prefs} Create Dictionary download.default_directory=${download_directory} plugins.plugins_disabled=${disabled}
Call Method ${chrome options} add_experimental_option prefs ${prefs}
Call Method ${chrome_options} add_argument no-sandbox
Create Webdriver Chrome chrome_options=${chrome options}
maximize browser window
Go To http://mysite.com

```

I have tried with option plugins.always\_open\_pdf\_externally ${True} and ${False}  
Also tried this option -plugins.plugins\_disabled=${disabled}

But pdf is still opened in chrome viewer.

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [17 February 2023 21:53 UTC](https://forum.robotframework.org/t/disable-chrome-pdf-viewer-option-not-working-in-robot-framework/5332/2 "2023-02-17T21:53:02Z")

</div>

Hi @bk-user,

I’ll suggest trying to approach from a different angle, rather than trying to disable the pdf viewer, why not try right click the link and save as?

[Click Element](https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html#Click%20Element) has a modifier option you could add a control key to that and get a context menu, then potentially [Press Keys](https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html#Press%20Keys) to send a `s` and a `RETURN`

I’ve never done it either way just offering suggestions,

Dave.

---

<div class="post-metadata">

**Author:** ![madb1ker](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/madb1ker/32/2909_2.png) [@madb1ker](https://forum.robotframework.org/u/madb1ker)\
**Post date:** [6 September 2023 16:43 UTC](https://forum.robotframework.org/t/disable-chrome-pdf-viewer-option-not-working-in-robot-framework/5332/3 "2023-09-06T16:43:13Z")

</div>

try this:

```
    ${browser_prefs} Create Dictionary download.default_directory=${REPORTS_DIR} plugins.always_open_pdf_externally=${True}
Open Browser about:blank ${BROWSER} options=add_experimental_option("prefs",${browser_prefs})

```

This will automatically download the file to the given directory.

---

<div class="post-metadata">

**Author:** ![CharlieScene](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/charliescene/32/3484_2.png) [@CharlieScene](https://forum.robotframework.org/u/CharlieScene)\
**Post date:** [18 February 2024 11:15 UTC](https://forum.robotframework.org/t/disable-chrome-pdf-viewer-option-not-working-in-robot-framework/5332/4 "2024-02-18T11:15:01Z")

</div>

Hi,

I have been using the pdf download solution, associated with a reopening of the file in case I need to capture visual proof.  
Py2PDF is used to control Pdf content.

However opening with Chrome Viewer is still an issue, as interacting with the viewer page and its shadow-Dom is quite complicated.

For example in the case on a multi page Pdf with need to scroll to a specific locator/object present in document (i.e. a logo) I was wondering if there were some solutions, or other libraries that would do the job ?

I’m using also SikuliX library, so the main concern would be to scroll down to a specific part/paragraph in the case of a logo, then use SikuliX to get the target.

Thanks for your ideas !
