0 votes
1 view
in Devops and Agile by (16.1k points)

I have seen lots of questions and solutions on File upload using Selenium WebDriver on Stack Overflow. But none of them are working for the following scenario.

Someone has given a solution as following

// assuming driver is a healthy WebDriver instance

WebElement fileInput = driver.findElement(By.name("uploadfile"));

fileInput.sendKeys("C:/path/to/file.jpg");

But still I can't find window handle. How can I work on that?

Screenshot

I am looking for a solution to the scenario above.

Please check this on any of the following websites.

http://www.uploadify.com/demos/

http://www.zamzar.com/

1 Answer

0 votes
by (44k points)

Use the below code:

public void test() {

WebDriver driver = new FirefoxDriver();

driver.get("http://www.freepdfconvert.com/pdf-word");

driver.findElement(By.id("clientUpload")).click();

driver.switchTo() .activeElement().sendKeys("/home/likewise-open/GLOBAL/123/Documents/filename.txt");

driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);

driver.findElement(By.id("convertButton"));

...