When I click on Print link in chrome browser , a pop is opened which shows it as a PDF file and then on the right side there are printing options with save , print etc buttons . Now when I click the print button which is on Browser , this pop up opens and the execution just pauses and I am stuck .

  • also looking for solution. any update?
    – H. Motsu
    Commented Mar 25, 2023 at 17:13

1 Answer 1


This would help you. I have tried a sample run with W3 school print example.

            WebDriver driver=new ChromeDriver();
            //js executor to prevent print function

This will not make the print action so that print dialog box will not be popped up.

  • hi , Thanks for the answer . i tried the above like this below but executions pauses after click . detailsPage.getAlertDetailsPrint1().click(); getDriver().switchTo().frame("iframeResult"); // js executor to prevent print function ((JavascriptExecutor) getDriver()).executeScript("window.print=function(){};"); getDriver().findElementByXPath(("//button[@onclick=\"window.print()\"]")).click();
    – Liza
    Commented Jul 17, 2020 at 20:52
  • i need to click print button on applictaion page , which makes this pop up appear and i need to verify it this pop up appears and then click cancel
    – Liza
    Commented Jul 17, 2020 at 21:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.