如何使用Selenium Webdriver和Firefox检测所有下载何时完成 [英] How to detect when all downloads finished with Selenium Webdriver and Firefox

查看:694
本文介绍了如何使用Selenium Webdriver和Firefox检测所有下载何时完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个执行多个操作并开始下载多个文件的FirefoxDriver实例.这些文件可能有各种大小,当它完成循环并关闭时,将中断未完成的下载.有没有一种方法可以检查是否有未完成的下载,然后等到所有下载完成后再关闭Firefox Window?这是针对VB.NET的,但我也可以理解C#解决方案.谢谢!

I have an instance of FirefoxDriver that performs several operations and starts downloading several files. Those files may have various sizes and when it finishes the loop and shuts down it interrupts unfinished downloads. Is there a way I can check whether there are pending downloads and then wait until they are all complete before closing Firefox Window? This is for VB.NET but I can understand C# solutions too. Thanks!

推荐答案

Firefox和Chrome在下载文件时会创建文件和中间文件扩展名.对于chrome,它是 crdownload ,我不记得它在Firefox中是什么.但是,您可以下载大文件并进行检查.下载完成后,该中间文件将重命名为实际文件名.

Firefox and Chrome when downloads a file creates and intermediate file extensions. For chrome it's crdownload, I don't remember what it's for Firefox. However, you can download a large file and check. Once download is completed this intermediate file is renamed to actual file name.

所有您需要做的就是编写代码,检查是否存在任何具有crdownload扩展名的文件.如果没有,则说明下载已完成.

All you need to do it write a code which check if any file with crdownload extension is exist or not. if not, your download is completed.

这篇关于如何使用Selenium Webdriver和Firefox检测所有下载何时完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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