简体   繁体   English

如何使用Selenium Webdriver获得下载文件的文件大小?

[英]How to get the file size of a downloaded file using Selenium Webdriver?

How to get the file size of a downloaded file of specific name using the Selenium Web Driver ?? 如何使用Selenium Web驱动程序获取特定名称的已下载文件的文件大小? Please Help 请帮忙

You can try the following code: 您可以尝试以下代码:

URLConnection conn = url.openConnection();
long fileLength = conn.getContentLengthLong();

In Java 在Java中

you can do it with just two lines of code. 您只需两行代码就可以做到。

File file = new File("path//to//your//file.txt");
System.out.println(file.length());

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM