WBPHELP FebKaya
WBPHELP FebKaya

Reputation: 1

Is there any solution to deal "Save as pdf" pop up for window print function in Selenium Web driver?

I want to save the Webpage content as pdf, so when I'm trying to use the below code

((JavascriptExecutor)DriverHolder.getDriver()).executeScript("window.print=function(){};");  
   DriverHolder.getDriver().findElement(By.xpath("//button[@onclick=\"window.print()\"]")).click();

"Save As pdf" pop up is appearing, is there any way to save the pdf?

enter image description here

Upvotes: 0

Views: 442

Answers (1)

red
red

Reputation: 27

just get that save button element and click it will get saved see how

In my case it is

//*[@id="sidebar"]//print-preview-button-strip//div/cr-button[2]/text()

enter image description here

Upvotes: 1

Related Questions