Once clicking a download button, files will be downloaded. Before executing next code, it needs to wait until the download completes.
My code looks like this:
Well, your file is stored somewhere, right? So, check if it exists in file system
File f = new File(filePathString); do { Thread.sleep(3000); } while (f.exists() && f.length() == expectedSizeInBytes)