New to using Selenium:
I tried the following code in Selenium to open the print window, but unfortunately it doesn't seem to work
Keyboard keyboard = ((HasInputDevices)driver).getKeyboard();
keyboard.pressKey(Keys.ENTER);
keyboard.pressKey(Keys.chord(Keys.CONTROL, "p"));
However, when I utilized the code below to open the Print window, it was successful
((JavascriptExecutor) driver).executeScript("print()");
My main question is how can I both print the page and then close the print window afterwards?