-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample15_2.java
More file actions
34 lines (23 loc) · 823 Bytes
/
Example15_2.java
File metadata and controls
34 lines (23 loc) · 823 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package com.SeleniumTestingSamples.Examples;
import java.io.File;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
//15.2
//File Download
public class Example15_2 {
public static void main(String[] args) {
WebDriver driver = new ChromeDriver();
driver.get("https://www.leafground.com/file.xhtml");
WebElement downLoad = driver.findElement(By.xpath("//*[@id=\'j_idt93:j_idt95\']"));
downLoad.click();
File fileLocation = new File("C:\\Users\\Admin\\Downloads");
File[] totalFiles = fileLocation.listFiles();
for (File file: totalFiles) {
if(file.getName().equals("TestLeaf Logo.png"))
System.out.println("File Download Success");
break;
}
}
}