0

I am making google chrome extension project, where i need to close print preview window from my jquery code. Print preview window open automatically when i call site option from my google chrome extension project.

enter image description here

I have also try with --disable-print-preview. in this case open print popup. so if anyone have idea to close print popup with jquery then it's also suitable for me.

Mehul Prajapati
  • 33
  • 1
  • 11

2 Answers2

0

[ I have found the solution to cancel the browser print preview screen. here is the solution provided in Java by "Erçin Akçay"

// Choosing the second window which is the print dialog.
// Switching to opened window of print dialog.
driver.switchTo().window(driver.getWindowHandles().toArray()[1].toString());

// Run javascript code for cancelling print operation.
// This code only executes for Chrome browsers.
JavascriptExecutor executor = (JavascriptExecutor) driver.getWebDriver();
executor.executeScript("document.getElementsByClassName('cancel')[0].click();");

// Switches to main window after print dialog operation.
driver.switchTo().window(driver.getWindowHandles().toArray()[0].toString());
0

You just need to disable the print preview using given line below. You can use before clicking on the print button.

((JavascriptExecutor)driver).executeScript("window.print=function(){};");