【问题标题】:Can selenium be used to click on print and then save as pdf?硒可以用来点击打印然后另存为pdf吗?
【发布时间】:2019-08-21 15:22:00
【问题描述】:

我正在尝试以 pdf 格式下载一些受密码保护的 url。我用 selenium 访问它们,但是我所有的 html 到 pdf 的努力最终要么破坏了最终 pdf 的格式,要么不保留字符集。是否可以在 safari 中使用 selenium 右键单击​​-打印-另存为 pdf?

【问题讨论】:

标签: python selenium pdf safari


【解决方案1】:

Selenium Web 驱动程序中的右键单击操作可以使用 Actions 类来完成。右键单击操作在 Selenium 中也称为上下文单击。 Actions类提供的预定义方法context click用于执行右键操作。下面是使用 Actions 类演示右键操作的代码。

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

Actions 类用于您可能需要的任何特殊输入,以模拟真实用户使用键盘或鼠标在页面上执行操作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-05-17
    • 2021-02-12
    • 1970-01-01
    • 1970-01-01
    • 2013-10-26
    • 2021-11-14
    • 2010-11-06
    相关资源
    最近更新 更多