0
我正在爲我的網站自動化文件上傳。我使用FF 31,硒2.39。我看到的問題是使用下面的java代碼的文件上傳在Chrome 37上工作,但在FF 31上無法工作。 我試圖使用selenium 43和selenium 39來處理FF 28-31版本,所以沒有結果。然後我添加了不透明度的內聯樣式,從0開始設置爲1,因爲輸入元素的樣式不可見使用javascript。執行javascript後,我打印出特性。我看到該元素已啓用並顯示,並將不透明度設置爲1,這就是我應用的所有更改。儘管我確實想到了AutoIT,但我並不想爲自己添加其他工具併爲自己購買更多麻煩(我的網站/ selenium/browser/autoit之間的兼容性問題)。您可以向我們推薦一些東西我可以解決這個問題嗎?sendkeys不起作用用於文件輸入selenium 2.39 Firefox 31
WebElement input = driver.findElement(By.xpath("//input[@id='img']"));
input.sendKeys("C:/Pictures/img1.gif");
final JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("document.getElementById('img').style.opacity=\"1\";");
<i class="coral-Icon">
<input id="img" class="FileUpload" type="file" onchange="preview();" data-upload-url="URL" name="file">
</i>
System.out.println("enabled??== " + input.isEnabled()+ " === "+ input.isDisplayed()+" style "+ input.getAttribute("style"));
console-output : enabled??== true === true style opacity: 1;