# Unable to click on the Print button in chrome browser

**URL:** <https://forum.robotframework.org/t/unable-to-click-on-the-print-button-in-chrome-browser/5306>\
**Category:** Robot Framework\
**Created:** [13 February 2023 06:32 UTC](https://forum.robotframework.org/t/unable-to-click-on-the-print-button-in-chrome-browser/5306 "2023-02-13T06:32:43Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![happyhsj](https://avatars.discourse-cdn.com/v4/letter/h/a88e4f/32.png) [@happyhsj](https://forum.robotframework.org/u/happyhsj)\
**Post date:** [13 February 2023 06:32 UTC](https://forum.robotframework.org/t/unable-to-click-on-the-print-button-in-chrome-browser/5306/1 "2023-02-13T06:32:43Z")

</div>

I am working on a web based automation.

In the web page, i have option to click on the “Print” and when i click on the Print, a pop up window appears to print the page and its has “Print / Save” and “Cancel” option,

But here is the problem: I couldn’t click on the “Print / Save” and “Cancel” options with RF.

I have tried,

1. Send Keys None RETURN
2. Click element

But no result. Need assistance please

---

<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:** [13 February 2023 07:04 UTC](https://forum.robotframework.org/t/unable-to-click-on-the-print-button-in-chrome-browser/5306/2 "2023-02-13T07:04:46Z")

</div>

Hi Harpreet,

You could try using [Handle Alert](https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html#Handle%20Alert) (assuming you are using SeleniumLibrray, you didn’t say??), failing that you might need to resort to a desktop automation library like one of these

- [flaui](https://gdatasoftwareag.github.io/robotframework-flaui/keywords/2.0.1.html)
- [SikuliLibrary](https://rainmanwy.github.io/robotframework-SikuliLibrary/doc/SikuliLibrary.html)
- [ImageHorizonLibrary](https://eficode.github.io/robotframework-imagehorizonlibrary/doc/ImageHorizonLibrary.html)

Dave.

---

<div class="post-metadata">

**Author:** ![happyhsj](https://avatars.discourse-cdn.com/v4/letter/h/a88e4f/32.png) [@happyhsj](https://forum.robotframework.org/u/happyhsj)\
**Post date:** [13 February 2023 08:32 UTC](https://forum.robotframework.org/t/unable-to-click-on-the-print-button-in-chrome-browser/5306/4 "2023-02-13T08:32:18Z")

</div>

\*\*\* Settings \*\*\*

Library SeleniumLibrary  
Library String  
Library Collections  
Library OperatingSystem  
Library DateTime

\*\*\* Variables \*\*\*

\*\*\* Test Cases \*\*\*  
Should be able to print the dashboads  
[Documentation] Download the report from Qualys  
#robot -d results .\Tests\qualys.robot  
log Starting the test case  
open browser [Creating a Print Button](https://wcmshelp.ucsc.edu/advanced/print-button.html) chrome  
sleep 5s  
maximize browser window  
click element xpath=//\*[@id=“main”]/div[2]/div/button  
sleep 2s  
press keys None ENTER

Hi Dave,

Thank you for the reply

---- Thisis the code i am trying to run. When i hit the Print button, a pop up appear for “Print Preview” and the script actually go to executing status for long time and it never go to the next line of code which is “press keys None ENTER”.

---

<div class="post-metadata">

**Author:** ![Many](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/many/32/658_2.png) [@Many](https://forum.robotframework.org/u/Many)\
**Post date:** [13 February 2023 08:36 UTC](https://forum.robotframework.org/t/unable-to-click-on-the-print-button-in-chrome-browser/5306/5 "2023-02-13T08:36:06Z")

</div>

If you just want to confirm the Printing automatically, I recommend to look into the **–kiosk-printing** argument in Chrome.  
The issue below is from Playwright, but the chrome option is also available if you are using Selenium.  
Using that option will confirm the Printing automatically. So the Print Dialog will not pop up.

> <https://github.com/microsoft/playwright-python/issues/739>
>
> Hi All
> 
> I would like to know how to handle on after clicked browser print butt…on.
> My case is the web page has print button, after clicked it would show the browser print view.
> I would like to click on "Print" button default it is Print to PDF.
> 
> I tried many way (page expect\_popup, context expect\_page, etc), all failed with timeout 
> 
> \`\`\`python
> from playwright.sync\_api import sync\_playwright
> import os
> 
> with sync\_playwright() as p:
> b = p.chromium.launch(headless=False,downloads\_path=os.getcwd())
> p = b.new\_page(accept\_downloads=True)
> p.goto('https://www.google.com/maps/dir/40.4515849,-3.6903752/41.380896,2.1228198/@40.9284811,-5.2705186,6z/am=t/data=!3m1!4b1?hl=en')
> p.click('button\[aria-label\*="Print"\]')
> p.waitForSelector('button\[jsaction="pane.action.printWithMaps"\]', state='visible')
> p.click('button\[jsaction="pane.action.printWithMaps"\]')
> p.waitForSelector('button\[jsaction="print.print"\]', state='visible')
> p.click('button\[jsaction="print.print"\]')
> with p.expect\_popup() as popup\_info:
> p.click('button\[jsaction="print.print"\]')
> popup = popup\_info.value
> popup.wait\_for\_load\_state()
> print(popup.title())
> \`\`\`
> 
> Thank you,
> Leo

[https://peter.sh/experiments/chromium-command-line-switches/#kiosk-printing](https://peter.sh/experiments/chromium-command-line-switches/#kiosk-printing)

---

<div class="post-metadata">

**Author:** ![happyhsj](https://avatars.discourse-cdn.com/v4/letter/h/a88e4f/32.png) [@happyhsj](https://forum.robotframework.org/u/happyhsj)\
**Post date:** [13 February 2023 09:11 UTC](https://forum.robotframework.org/t/unable-to-click-on-the-print-button-in-chrome-browser/5306/6 "2023-02-13T09:11:23Z")

</div>

> [@Many](#):
>
> –kiosk-printing

I am just looking to hit the “Print button / Save button” automatically. The xpath doesn’t work for me.

---

<div class="post-metadata">

**Author:** ![Many](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/many/32/658_2.png) [@Many](https://forum.robotframework.org/u/Many)\
**Post date:** [13 February 2023 09:28 UTC](https://forum.robotframework.org/t/unable-to-click-on-the-print-button-in-chrome-browser/5306/7 "2023-02-13T09:28:46Z")

</div>

If you use the kiosk printing mode in chrome, this dialog will be handled automatically by the browser and no additional steps to click the buttons will be needed

---

<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:** [13 February 2023 09:42 UTC](https://forum.robotframework.org/t/unable-to-click-on-the-print-button-in-chrome-browser/5306/8 "2023-02-13T09:42:35Z")

</div>

Hi Harpreet,

I have no real experience with this, I do remember there was a post in the forum a while back (can’t find it now) where the person solved the problem using [SikuliLibrary](https://rainmanwy.github.io/robotframework-SikuliLibrary/doc/SikuliLibrary.html)

Here are a couple of threads I found that are related:

- [Detection of Firefox File Download pop up - #4 by HelioGuilherme66](https://forum.robotframework.org/t/detection-of-firefox-file-download-pop-up/3251/4)
- [RPA - Selenium creates a Print dialog and stops execution](https://forum.robotframework.org/t/rpa-selenium-creates-a-print-dialog-and-stops-execution/262)

Hopefully that helps?

Dave.

---

<div class="post-metadata">

**Author:** ![happyhsj](https://avatars.discourse-cdn.com/v4/letter/h/a88e4f/32.png) [@happyhsj](https://forum.robotframework.org/u/happyhsj)\
**Post date:** [13 February 2023 12:18 UTC](https://forum.robotframework.org/t/unable-to-click-on-the-print-button-in-chrome-browser/5306/9 "2023-02-13T12:18:31Z")

</div>

Thank you Dave, I will have a look.

---

<div class="post-metadata">

**Author:** ![pepijn](https://avatars.discourse-cdn.com/v4/letter/p/f1d935/32.png) [@pepijn](https://forum.robotframework.org/u/pepijn)\
**Post date:** [8 January 2024 16:10 UTC](https://forum.robotframework.org/t/unable-to-click-on-the-print-button-in-chrome-browser/5306/10 "2024-01-08T16:10:35Z")

</div>

We had the same problem. We wanted to check the content of the pdf so had to download it in some way.

> <https://stackoverflow.com/questions/72052662/how-to-specify-print-location-for-pdf-printing-with-selenium>

helped us solve the problem.  
how we now have it:

> ```
> ${printJson}= catenate
> ... {"recentDestinations": [{"id": "Save as PDF", "origin": "local", "account": "" }],"version":2,"isGcpPromoDismissed":false,"selectedDestinationId": "Save as PDF"}
> ${pref}= Create Dictionary
> ... prompt_for_download=${False}
> ... download.default_directory=${downloadLocation}
> ... savefile.default_directory=${downloadLocation}
> ... download.directory_upgrade=${True}
> ... printing.print_preview_sticky_settings.appState= ${printJson}
> Open Browser
> ... ${url}
> ... ${BROWSER}
> ... options=add_experimental_option("prefs",${pref}); add_argument('--kiosk-printing')
> 
> ```
