Unable to click on the Print button in chrome browser

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

Hi Harpreet,

You could try using Handle Alert (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

Dave.

*** 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 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”.

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://peter.sh/experiments/chromium-command-line-switches/#kiosk-printing

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

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

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

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

Hopefully that helps?

Dave.

Thank you Dave, I will have a look.

1 Like

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

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')