In this post, we will see Selenium File Upload | Selenium File Upload by sendKeys() | Selenium WebDriver Java
Program Code (UploadFile.java):
package main;
import java.time.Duration;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class UploadFile {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "C:\\selenium\\chromedriver_win32\\chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.get("https://www.w3schools.com/howto/howto_html_file_upload_button.asp");
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(5));
driver.findElement(By.xpath("//input[@id='myFile']")).sendKeys("C:\\Users\\parag\\Desktop\\Class Time Tables\\Class TT BE-1.pdf");
}
}
Watch following video:
Watch on YouTube: https://www.youtube.com/watch?v=A9ekHRBpYT0
No comments:
Post a Comment