Ok I think I solved it.
WebElement fileInput = driver.findElement(By.id("document")); JavascriptExecutor js = (JavascriptExecutor) driver; WebElement element = driver.findElement(By.id("document")); js.executeScript("arguments[0].setAttribute('style', 'left:30px')", element); fileInput.sendKeys(fileName);
bootstrap-filestyle.js hides the input element, so you need to move it to the visible area and then set it in the standard way.
so many problems for such an easy solution.
Here is my original html code:
<span id="documentUpload"> <input type="file" id="document" name="document" class="notMandatory" onkeypress="return noenter(event)" tabindex="-1" style="position: absolute; left: -9999px;"> <div class="bootstrap-filestyle" style="display: inline;" tabindex="0"> <input type="text" class="input-xlarge" disabled="" autocomplete="off"> <label for="document" class="btn"><i class="icon-folder-open"></i> <span>Upload</span></label> </div> </span>
source share