当前IE不支持使用Selenium Webdriver 2.42.000进行文件上传 [英] Current IE doesn't support file upload using Selenium Webdriver 2.42.000
问题描述
driver.findElement(By.id( 文件上传))的SendKeys(文件路径)。
其中 id = fileUpload
type = file
并且这个字段是一个隐藏字段。
任何想法:
org.openqa.selenium.ElementNotVisibleException:元素不显示(警告:服务器没有提供任何堆栈跟踪信息)
命令持续时间或超时: 30毫秒
构建信息:版本:'2.44.0',修订版本:'76d78cf323ce037c5f92db6c1bba601c2ac43ad8',时间:'2014-10-23 13:11:40'
系统信息:主机:'XXXXXXX', ip:'192.168.12.24',os.name:'Windows 7',os.arch:'x86',os.version:'6.1',java.version:'1.8.0_40'
驱动程序信息:org .openqa.selenium.ie.InternetExplorerDriver
Capabilities [{browserAttachTimeout = 0,enablePersistentHover = false,ie.forceCreateProcessApi = false,ie.usePerProcessProxy = false,ignoreZoomSetting = false,handlesAlerts = true,version = 11,platform = WINDOWS ,nativeEve nts = 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}]
会话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]
这是IEDriver的一个已知问题,将在下一个版本中解决。隐藏的文件输入标签在IE上不起作用,就像在其他浏览器上一样。查看此处所记录的问题。我已经回答了类似的问题此处
编辑
这是个好消息。刚刚确认硒版本2.46有变化。请参阅更新日志。所以升级,它应该工作
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]
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
这篇关于当前IE不支持使用Selenium Webdriver 2.42.000进行文件上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!