如何在chromedriver 2.15中打开pdf而不下载它 [英] How to open pdf in chromedriver 2.15 without downloading it

查看:212
本文介绍了如何在chromedriver 2.15中打开pdf而不下载它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近升级到了Chromedriver 2.15

I recently upgraded to Chromedriver 2.15

现在,当我单击指向pdf文件的链接时,它会自动下载,而不是像以前一样在新标签中显示.

Now, when I click a link to a pdf file it is auto-downloading instead of displaying in a new tab as before.

<a id="my_pdf_file" format="pdf" target="_blank" href="/my_pdf_file.pdf">My PDF File</a>

是否可以恢复在新标签页中显示pdf的旧行为?

Is there a way to resume the old behavior of displaying the pdf in a new tab?

推荐答案

当前是Chrome(不是Chromedriver)存在的未解决问题:

This is currently an open issue with Chrome, not Chromedriver:

自升级到v 42.0.2311.90后无法在chrome中打开PDF文件

在M41和M42之间的某个时刻,--test-type开关的行为已更改,因此下载了PDF,而不是显示它们.

At some point between M41 and M42, the behavior of the --test-type switch was changed so that PDFs are downloaded instead of displayed.

我更新到了Chrome 44.0.2391.0 dev-m (64 bit)的dev分支的最新版本,在Selenium中运行了一个测试,该测试打开了PDF,并且可以确认默认情况下在新选项卡中打开了PDF.

I updated to the latest version of the dev branch of Chrome 44.0.2391.0 dev-m (64 bit), ran a test in Selenium that opens a PDF, and can confirm that PDFs are opening in new tabs by default.

已使用以下工具对此进行了测试:

This was tested using the following:

Chrome 44.0.2391.0 dev-m (64 bit)
Selenium 2.45
Chrome Driver 2.15

因此,您可以使用Chrome的开发版,直到发行版赶上来为止,或者尝试上面链接中的一种解决方法,或者在知道其很快会被修复的情况下等待.

So, you can either use the dev version of Chrome until the release version catches up, try one of the workarounds in the link above, or wait with the knowledge that it will get fixed soon.

这篇关于如何在chromedriver 2.15中打开pdf而不下载它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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