Adam Sh
Adam Sh

Reputation: 8577

WebDriver / stuck when open upload file window

I use my WebDriver, with FireFox.

I have an elemnt: //input[@class="uploadFiles"], when I click on it by: driver.findElement(By.xpath("//input[@class="uploadFiles"]")), a windows of upload a file (Windows OS's window) is opened, but the test doesn't continue to the next line, and get stuck.

Any help?

Upvotes: 3

Views: 2576

Answers (4)

GirishB
GirishB

Reputation: 544

I faced the same problem with FF, then I found that it was specific to the FF version I am using. I installed and ran the tests on FF 11, and I was able to successfully runt he tests. Try changing the version of FF that you are using.

Upvotes: 0

Umamaheshwar Thota
Umamaheshwar Thota

Reputation: 521

You can't interact with OS level Windows directly. You can go through the path given by niharika_neo or else you can use Auto IT tool for handling the OS level windows. The best option is to use Auto IT tool.

Upvotes: 1

Sanja Melnichuk
Sanja Melnichuk

Reputation: 3505

No you cant do it with WebDriver as niharika_neo answer but you can do next:

string filepath = "my local path";
_driver.FindElement(By.Id("attachments")).SendKeys(filepath);
_driver.FindElement(By.Id("attachments")).SendKeys(Keys.Return);

Upvotes: 2

niharika_neo
niharika_neo

Reputation: 8531

Webdriver doesnt interact with os level dialogs and that's the reason it doesnt continue to the next line. Here's something to help you : http://code.google.com/p/selenium/wiki/FrequentlyAskedQuestions#Q:_Does_WebDriver_support_file_uploads?

Upvotes: 2

Related Questions