TransWikia.com

How to handle this below window/pop up in chrome when i click on print link . I need to recognize it and click cancel on it

Software Quality Assurance & Testing Asked on October 25, 2021

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 .

One Answer

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


            WebDriver driver=new ChromeDriver();
            System.setProperty("webdriver.chrome.driver","driverpath");
            driver.get("https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_print");
            driver.switchTo().frame("iframeResult");
            //js executor to prevent print function
            ((JavascriptExecutor)driver).executeScript("window.print=function(){};");
            driver.findElement(By.xpath("//button[@onclick="window.print()"]")).click();
            

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

Answered by Mohamed Sulaimaan Sheriff on October 25, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP