How to check if a file got downloaded in java selenium tests

//we use import java.io.File;
File f = new File("D:\\program.txt");
f.exists(); // this will print true or false whether the file program.txt exists
public ExpectedCondition<Boolean> filepresent() {
return new ExpectedCondition<Boolean>() {
@Override
public Boolean apply(WebDriver driver) {
File f = new File("D:\\program.txt");
return f.exists();
}
@Override
public String toString() {
return String.format("file to be present within the time specified");
}
};
}
WebDriverWait wait = new WebDriverWait(driver,Duration.ofSeconds(2));
wait.until(pageobject.filepresent());

An ISTQB certified Software Test Engineer and an enthusiastic fast learner with a passion for technology. linkedin : https://www.linkedin.com/in/praveendvd

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store