Upload file using Selenium (SendKeys Method)

package com.test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
  public class UploadFile{

  public static void main(String[] args) {  

  WebDriver driver = new FirefoxDriver();

// Web element of Upload file & valid absolute path of the file
  WebElement fileInput = driver.findElement(By.name("uploadFileInput"));
  fileInput.sendKeys("provide a valid absolute path of the file");

//Web element of Upload Button
  WebElement ButtonFile = driver.findElement(By.name("uploadFileButton"));

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s