简体   繁体   中英

Selenium remote file upload not working on Firefox Browser

I want to remotely upload the file using selenium. My code is working fine on Chrome , but is not throwing the following error on 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)**

I am using the latest versions of both Firefox and Selenium .

You probably need to set the file detector if you are running a remote instance:

driver.setFileDetector(new LocalFileDetector());

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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