下载完成后自动关闭firefox [英] close firefox automatically when download is complete
问题描述
我正在使用selenium webdriver做一些使用firefox的下载。目前,我的脚本等待下载已经启动的特定时间,然后关闭Firefox。我想知道是否有一种方法来配置firefox在下载完成时自动关闭?或者使用selenium webdriver,我可以检查下载是否已经完成?我不想使用任何添加,因为它可能会增加我的脚本中的依赖。我不能使用wget / curl等下载文件。
提前感谢
I'm using selenium webdriver to do some downloading using firefox. At the moment my script waits for a specific time after download has inititated and then close the firefox. I want to know if there is a way to configure firefox to automatically close on download completions? Or using selenium webdriver, can I check if download has been completed? I don't want to use any add on, as it might add dependency in my script. I cant use wget/curl etc to download the files. Thanks in advance
推荐答案
什么Ignacio Contreras说。轮询下载路径可能是最好的(最强大的)解决方案。
What Ignacio Contreras said. Polling the download path is possibly the best (most robust) solution.
替代#1:
使用 FirefoxProfile
与下载状态栏插件。它有一个方便的选项,在窗口关闭后继续下载下载管理器(或类似的东西),以便它将保持Firefox在后台运行,直到下载完成。
Use a FirefoxProfile
with Download Statusbar addon. It has a handy option to "Continue downloading in Download manager after window has been closed" (or something very similar), so that it will keep Firefox running in the background until the download has been finished.
替代#2:
使用此(或任何其他类似的WebDriver友好工具)...或如果可以,此。这将彻底削减Firefox的进程。
Download the file directly using this (or any other similar WebDriver-friendly tool) ... or this, if you can. That will totally cut Firefox out of the process.
这篇关于下载完成后自动关闭firefox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!