一旦點擊下載按鈕,文件將被下載。在執行下一個代碼之前,它需要等到下載完成。 我的代碼如下所示:等待下載完成在selenium webdriver JAVA
Thread.sleep(2000);
driver.findElement(By.xpath("//*[@id='perform']")).click();//click for download
Thread.sleep(20000);
//code to be executed after download completes
Readfile fileobj=new Readfile();
String checkfile=fileobj.checkfilename();
我怎樣才能讓webdriver的等待,直至下載完成?
你有問題嗎? –
如何讓webdriver等待下載完成 – qaepk
這超出了WebDriver的功能,一旦下載開始,它就不再是瀏覽器操作,因此WebDriver無法如此控制它。看看這個博客文章,這是非常豐富的,當談到這個話題。 http://ardesco.lazerycode.com/index.php/2012/07/how-to-download-files-with-selenium-and-why-you-shouldnt/ –