Current IE doesn't support file upload using S

2019-09-17 01:17发布

问题:

Currently I was able to upload the file using selenium webdriver version 2.42.00 with browser chrome while I couldn't able to do it the same with Internet Explorer version 11.

driver.findElement(By.id("fileUpload")).sendKeys(filePath);

where id = fileUpload is for input element with type=file and this field is a hidden field.

Any thoughts on it:

org.openqa.selenium.ElementNotVisibleException: Element is not displayed (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 30 milliseconds Build info: version: '2.44.0', revision: '76d78cf323ce037c5f92db6c1bba601c2ac43ad8', time: '2014-10-23 13:11:40' System info: host: 'XXXXXXX', ip: '192.168.12.24', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_40' Driver info: org.openqa.selenium.ie.InternetExplorerDriver Capabilities [{browserAttachTimeout=0, enablePersistentHover=false, ie.forceCreateProcessApi=false, ie.usePerProcessProxy=false, ignoreZoomSetting=false, handlesAlerts=true, version=11, platform=WINDOWS, nativeEvents=true, ie.ensureCleanSession=false, elementScrollBehavior=0, ie.browserCommandLineSwitches=, requireWindowFocus=true, browserName=internet explorer, initialBrowserUrl=http://localhost:7704/ takesScreenshot=true, javascriptEnabled=true, ignoreProtectedModeSettings=false, enableElementCacheCleanup=true, cssSelectorsEnabled=true, unexpectedAlertBehaviour=dismiss}] Session ID: cfa81fae-4ea2-43b9-9e3a-69135462fe82 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_40] at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[na:1.8.0_40] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[na:1.8.0_40]

回答1:

It is a known issue with IEDriver which is going to be resolved in next release. Hidden file input tag will not work on IE as it does on other browsers. See the issue logged here. I have answered a similar question here

EDIT

Here is the good news. Just confirmed the Selenium version 2.46 has the changes. See changelog. So upgrade and it should work