简体   繁体   English

硒可以用于单击打印,然后另存为pdf吗?

[英]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. 我正在尝试以PDF格式下载许多受密码保护的网址。 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. 我使用硒访问它们,但是我所有的html至pdf努力最终要么破坏了最终pdf中的格式,要么不保留字符集。 Is it possible to use selenium to right click-print-save as pdf in safari? 可以在浏览器中使用硒右键单击以pdf格式保存吗?

Right click action in Selenium web driver can be done using Actions class. 可以使用Actions类在Selenium Web驱动程序中右键单击动作。 Right Click operation is also called Context Click in Selenium. 右键单击操作在Selenium中也称为“上下文单击”。 Pre-defined method context click provided by Actions class is used to perform right click operation. Actions类提供的预定义方法上下文单击用于执行右键单击操作。 Below is the code to demonstrate right click operation using Actions class. 下面的代码演示了使用Actions类的右键单击操作。

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. Actions类用于您可能需要的任何特殊输入,以使用键盘或鼠标在页面上执行操作来模拟真实用户。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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