Wait for Download to finish in selenium webdriver JAVA

后端 未结 13 1673
醉话见心
醉话见心 2020-12-01 14:38

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:

<
13条回答
  •  [愿得一人]
    2020-12-01 15:06

    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)
    

提交回复
热议问题