简体   繁体   中英

Can selenium be used to click on print and then save as pdf?

I am trying to download as pdfs a number of urls that are password protected. I access them with selenium, but all my html to pdf efforts end up either ruining the format in the final pdf or not preserving the character set. Is it possible to use selenium to right click-print-save as pdf in safari?

Right click action in Selenium web driver can be done using Actions class. Right Click operation is also called Context Click in Selenium. Pre-defined method context click provided by Actions class is used to perform right click operation. Below is the code to demonstrate right click operation using Actions class.

Actions actions = new Actions(driver);
WebElement elementLocator = driver.findElement(By.id("ID"));
actions.contextClick(elementLocator).perform();

Actions class is used for any special input you might need, to simulate real user using a keyboard or the mouse to perform an action on the page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM