Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
9 views
in DevOps and Agile by (19.7k 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 (62.9k 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"));

To learn in-depth about Selenium, sign up for an industry based Selenium course.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...