另存为PDF Chrome使用硒 [英] Save As PDF Chrome using selenium

查看:166
本文介绍了另存为PDF Chrome使用硒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找使用硒自动化另存为PDF的Chrome。 AFAIK并不支持Selenium开箱即用。因此,我正在努力写我自己的。我有问题。实际上,点击我的网页上的打印按钮打开一个可打印区域的新窗口。我正在尝试使用SwitchTo切换到此窗口。但它总是超时。

I am looking to automate "Save as PDF" of Chrome using selenium. AFAIK it is not supported by the Selenium out of the box. Therefore, i am trying to write my own. I am having an issue. Actually clicking on the Print button in my webpage opens a new window with printable area. I am trying to switch to this window using SwitchTo. But it is timing out always.

推荐答案

您可以添加options.AddArgument( - kiosk-printing);让它自动点击打印按钮。

You can add the options.AddArgument("--kiosk-printing"); to have it automatically click the print button.

这对我很有用,但我在将打印机设置为另存为PDF时遇到问题。它正在打印到打印机。

That is working for me but I have a problem setting the printer to Save as PDF. It is printing to the printer instead.

这篇关于另存为PDF Chrome使用硒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆