How do I verify if a file is being downloaded in Selenium Webdriver C#
var Path = "drive path";
ChromeOptions co = new ChromeOptions();
co.AddAdditionalCapability("download.default_directory", Path);
driver = new ChromeDriver(co);
Then you can you System.IO.DirectoryInfo for retrieving all downloaded file details into Path folder.
How to check if a file has been downloaded successfully with selenium webdriver?
This method work fine for me
public boolean validateFileDownloaded(String downloadPath, String fileName) {
for (int k = 0; k< 60; k++) {
File dir = new File(downloadPath);
File[] dirContents = dir.listFiles();
if(dirContents == null){
continue;
}
for (File dirContent : dirContents) {
if (dirContent.getName().contains(fileName)) {
return true;
}
}
wait(500);
}
return false;
}
Related Topics
How to Get Resources Directory Path Programmatically
How to Update a Jsf Component from a Jsf Backing Bean Method
How to Select One Object from the List of Objects
How to Split Single Row into Multiple Rows in Spark Dataframe Using Java
Mock User Console Input in Junit Test
Calling Mutiple Webservice At Same Time in Spring Java
Reading a Text File Character by Character into a 2D Array in Java
How to Change the Background Color of a Textfield Without Changing the Border in Javafx
Custom Pagination by Array List
Alternative to If-Else Statements or Better Approach
Getting Java.Lang.Classnotfoundexception: Javax.Servlet.Servletcontext in Junit
Spring Jpa/Hibernate Transaction Force Insert Instead of Update
How to Find Out If String Has Already Been Url Encoded
Disable Spring Security Config Class for @Webmvctest in Spring Boot
I Get a Status 200 When Connecting to the Websocket, But It Is an Error
How to Pass Variables Between Cucumber-Jvm Steps