I would like to print pages after each click in Chrome. So script should perform a click and after that send "CTRL+P" to open printing dialog and "ENTER" to save page as PDF file by default.
Asked
Active
Viewed 2,664 times
0
-
1Did [this work](https://forum.katalon.com/discussion/9776/send-keys-to-browser-dialog-windows)? – Mate Mrše Sep 27 '18 at 06:19
-
@MateMrše : Yes, that is a solution for the problem. – plaidshirt Sep 27 '18 at 07:18
-
You could post it as answer. – Mate Mrše Sep 27 '18 at 07:34
1 Answers
0
I got solution on Katalon forum: https://forum.katalon.com/discussion/9776/send-keys-to-browser-dialog-windows It is based on Java Robot class.
Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_CONTROL)
robot.keyPress(KeyEvent.VK_P)
// CTRL+P is now pressed
robot.keyRelease(KeyEvent.VK_P)
robot.keyRelease(KeyEvent.VK_CONTROL)
// CTRL+P is now released

plaidshirt
- 5,189
- 19
- 91
- 181