I have to click on an element to upload a CSV file with Selenium WebDriver in JUnit. The input looks like this:
<input type="file" name="upload0" size="56" value="" id="DateiImportSchritt2Csv_upload0"/>
If I click on that input element an OS window opens where I have to choose my file to upload. My problem is that if I use Selenium for clicking the input like this:
driver.findElement(By.xpath("//div[@id='wwctrl_DateiImportSchritt2Csv_upload0']/input")).click();
It does open the OS window, but freezes my whole test without any Exceptions. If I close the window manually, my test continues.
On another place in my code, I have to download a file. It is very similar, except it's not an input element but an anchor element (<a>) and it works fine there.
So how to click an input element which opens an OS window without freezing my test? Also tried submit(), but even the window does not open with that method.
I'm using:
Windows 7
Firefox 32.0.3
Selenium WebDriver 2.43.1
JUnit 4
Edit:
The whole div element looks like this:
<div class="group " id="wwctrl_DateiImportSchritt2Csv_upload0">
<label id="label_DateiImportSchritt2Csv_upload0" for="DateiImportSchritt2Csv_upload0">
<span>CSV-Importdatei für Ranglisten auswählen</span>
</label>
<p class="labelInfo" id="help_DateiImportSchritt2Csv_upload0">
Bitte wählen Sie eine für den Import bestimmte Datei aus.
</p>
<input type="file" name="upload0" size="56" value="" id="DateiImportSchritt2Csv_upload0"/>
</div>
There is no submit button. The input is also not used for typing, you can only click on it to open a window.