Absolute Xpath for fileupload button in the Selenium Webdriver

18 views
Skip to first unread message

murali krishna

unread,
Nov 29, 2017, 9:32:25 PM11/29/17
to Selenium Users
Hi All,

Request you to kindly help me in shortest way to find out the selenium code for below element (<input type = "file") :

Source Code as follows :

Inline image 2

I have tried different ways, unable to find out the proper solution for above element . Please have a look below ways that I have tried"

1.
//WebElement upl = driver.findElement(By.xpath(".//*[@id='AffidavitFileName']"));
//upl.sendKeys("C:\\Users\\User1\\Desktop\\Testing\\Img.jpg");

2.
//WebElement upld = driver.findElement(By.cssSelector("#AffidavitFileName"));

//upld.sendKeys("C:\\Users\\User1\\Desktop\\Testing\\Img.jpg");

3.
/String uploadfile = "\\Users\\user1\\Desktop\\Testing\\Test.jpg";
    //WebElement upd = driver.findElement(By.id("AffidavitFileName"));
    //upd.sendKeys(uploadfile);

4.
//WebElement upload = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//input[starts-with(@id,'AffidavitFileName')]")));
//upload.sendKeys("C:\\Users\\User1\\Desktop\\Testing\\Img.jpg");

5.
//WebElement file = driver.findElement(By.xpath("//div[@id='sbaClassifiedsection']/input[@id='AffidavitFileName']"));
//file.sendKeys("C:\\Users\\User1\\Desktop\\Testing\\Img.jpg");

6.
//WebElement upload = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//input[@type='file']")));
//upload.sendKeys("C:\\Users\\User1\\Desktop\\Testing\\Img.jpg");

7. 
//driver.findElement(By.xpath("//*[@id='sbaClassifiedsection']/div[1]/div[3]/div/span/span[1]")).click();
//Runtime.getRuntime().exec("C:/Selenium/Upload.exe");

8.
//WebElement upload = driver.findElement(By.xpath("html/body/div[3]/div[1]/div[3]/div/form/div[2]/div[2]/div[1]/div[3]/div/span/input"));
 //upload.sendKeys("C:\\Users\\User1\\Desktop\\Testing\\Img.jpg");


murali krishna

unread,
Nov 29, 2017, 9:38:29 PM11/29/17
to seleniu...@googlegroups.com
Hi All,

Request you to kindly help me in shortest way to find out the selenium code for below element (<input type = "file") :


Source Code as follows :

Inline image 1
source.png
Reply all
Reply to author
Forward
0 new messages