繁体   English   中英

Selenium远程文件上传在Firefox浏览器上不起作用

[英]Selenium remote file upload not working on Firefox Browser

我想使用Selenium远程上传文件。 我的代码在Chrome上运行正常,但在Firefox上未引发以下错误。

**org.openqa.selenium.UnsupportedCommandException: Unrecognized command: POST /session/a759b398-2adf-8343-8575-7c156f389289/file
Command duration or timeout: 6 milliseconds
Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
System info: host: 'Vaibhav.local', ip: '172.20.57.75', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.10.5', java.version: '1.8.0_66'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{applicationCacheEnabled=true, rotatable=false, handlesAlerts=true, databaseEnabled=true, version=46.0.1, platform=MAC, nativeEvents=false, acceptSslCerts=true, webStorageEnabled=true, locationContextEnabled=false, browserName=firefox, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: a759b398-2adf-8343-8575-7c156f389289
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:422)**

我正在使用FirefoxSelenium的最新版本。

如果正在运行远程实例,则可能需要设置文件检测器:

driver.setFileDetector(new LocalFileDetector());

WebElement element = driver.findElement(By.cssSelector("input[name='file']");
element.sendKeys("Path to file");

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM