本文介绍了是否可以使用Selenium Web驱动程序和一键构建Jenkins保存Adobe pdf文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的难题.我正在使用Java中的Selenium Web驱动程序编码来创建一些自动化测试.该软件的主要输出是在Adobe Acrobat中加载PDF.

Here's my dilemma. I'm creating some automation tests using selenium web driver coding in Java. The main output of the software is to load a PDF in adobe acrobat.

我也在使用Jenkins,这就是为什么出现问题的原因,因为我无法实际看到该软件创建的输出.

I'm also using Jenkins which is why my problem has come about as I wont be able to physically see the output created by the software.

测试完成后,可以将文件保存在某个位置吗?

Is it possible to save this file in a certain location when the test has completed?

推荐答案

此功能适用于Firefox:

This works with Firefox:

通过以下方式更改Selenium所使用的Firefox配置文件(最好按照以下说明在中创建专用配置文件) 工具->设置->应用程序,然后将文件类型PDF的操作更改为保存文件".

Change the Firefox profile used by Selenium (better to create a dedicated profile as described here) via Tools -> Settings -> Applications and change action of file type PDF to "Save file".

在这种情况下,要求打开文件或保存的窗口将显示,并且文件被安静地保存到配置的目录中(设置->常规->下载).

In that case the window asking to open file or save will not show up and the file is quietly saved to configured directory (Settings -> General -> Downloads).

请记住,您必须在本地以及在詹金斯都这样做.在这两种情况下,都必须告知WebDriver在启动时使用环境变量-Dwebdriver.firefox.profile使用此Firefox配置文件(如果有自定义配置文件,否则使用默认值).

Remember that you have to do that locally and in Jenkins as well. In both cases WebDriver has to be told to use this Firefox profile using environment variable -Dwebdriver.firefox.profile on startup (if there is a custom profile otherwise default is used).

您还可以设置以编程方式进行配置.这是一个使用python和CSV文件的示例,但是您应该可以将其转换为Java和PDF.

You can also set the profile programmatically. Here is an example in python and for CSV files but you should be able to transform that to Java and PDF.

这篇关于是否可以使用Selenium Web驱动程序和一键构建Jenkins保存Adobe pdf文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 14:50