2017-04-12 55 views
0

我使用此代碼進行下載。我的目標是在4個不同的位置下載此文件。此時該文件將進入默認下載文件夾。我可以使用Webdriver java下載多個文件夾中的單個文件嗎?

System.setProperty("webdriver.chrome.driver", 
      System.getProperty("user.dir") + "/src/Browser_Driver/chromedriver.exe"); 
WebDriver driver = new ChromeDriver(); 
driver.manage().timeouts().implicitlyWait(35, TimeUnit.SECONDS); 
driver.manage().window().maximize(); 

driver.get("https://support.spatialkey.com/spatialkey-sample-csv-data/"); 
driver.findElement(By.linkText("download .csv file")).click(); 
+0

沒有。唯一可以嘗試的是AutoIT和Robot類(不建議) – kushal

回答

0

這裏是解決你的問題:

您可以輕鬆地通過您所選擇的任何名稱下載同一個文件(例如,IEDriverServer_Win32_3.3.0.zip)(例如D_Dev.zip),並在任何(多)你希望的位置。爲此,你必須接受AutoIT的幫助。您需要安裝SciTE編輯器。寫一個簡單的腳本如下:

Example() 

Func Example() 
    Local $sFilePath1 = "D:\Downloads\D_Debanjan.zip" 
    Local $sFilePath2 = "E:\Downloads\E_Debanjan.zip" 
    Local $hDownload = InetGet("http://selenium-release.storage.googleapis.com/3.3/IEDriverServer_Win32_3.3.0.zip", $sFilePath1, $INET_FORCERELOAD) 
    Local $hDownload = InetGet("http://selenium-release.storage.googleapis.com/3.3/IEDriverServer_Win32_3.3.0.zip", $sFilePath2, $INET_FORCERELOAD) 

EndFunc 

這個簡單的腳本的名稱爲「D_Debanjan.zip」 &「E_Debanjan.zip」,其中「D_Debanjan.zip下載在2個不同的壓縮文件相同的「IEDriverServer.exe」 「保存在」D:\ Downloads \「&」E_Debanjan.zip「保存在」E:\ Downloads \「目錄中。

讓我知道這是否回答你的問題。

相關問題