使用selenium java在firefox gecko驱动程序中自动下载pdf

任何人都可以帮助创建配置文件并使用firefox( gecko 驱动程序 )设置选项,以自动下载selenium webdriver – java中的文件。 我已经搜索了很多谷歌搜索的选项,没有什么工作。 所以在堆栈溢出时发布我的查询。 如果可能,请帮助一些代码段。 这适用于selenium 3和firefox 52。

提前致谢。

1 /在firefox.exe -p中手动创建一个新的firefox配置文件

2 /使用这个新的配置文件运行firefox并设置为自动下载PDF文件

3 /使用这个:

@BeforeClass public static void setUpClass() { FirefoxOptions options = new FirefoxOptions(); ProfilesIni allProfiles = new ProfilesIni(); FirefoxProfile selenium_profile = allProfiles.getProfile("NAME OF THE NEW FIREFOX PROFILE"); options.setProfile(selenium_profile); options.setBinary("PATH TO FIREFOX.EXE"); System.setProperty("webdriver.gecko.driver", "PATH TO GECKODRIVER.EXE"); driver = new FirefoxDriver(options); driver.manage().window().maximize(); } 

使用现有的自定义firefox配置文件,您可以使用几乎任何firefox设置修改(代理设置,1个导入证书,无需询问,扩展等)运行测试

不再需要在代码中指定:

 FirefoxProfile selenium_profile = new FirefoxProfile(); selenium_profile.setPreference...