尝试通过 selenium 上传文件时出现以下错误。
org.openqa.selenium.WebDriverException: File not found: D:\Projekte\Ticket.xml (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 10 milliseconds
Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 16:57:40'
System info: host: 'r-177', ip: '172.16.18.177', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_79'
Session ID: ec651a7b-bca2-48f0-8dd3-9e3bfde44c1c
Driver info: org.openqa.selenium.firefox.MarionetteDriver
Capabilities [{platform=XP, specificationLevel=0, acceptSslCerts=false, browserVersion=47.0, browserName=Firefox, XULappId={ec8030f7-c20a-464f-9b0e-13a3a9e97384}, raisesAccessibilityExceptions=false, rotatable=false, appBuildId=20160604131506, takesElementScreenshot=true, command_id=1, version=, firefox_profile=UEsDBBQACAgIAE+LyUgAAAAAAAAAA..., platformVersion=6.1, platformName=Windows_NT, proxy={}, device=desktop, takesScreenshot=true}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:327)
at org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:122)
信息:两天前我使用了 FireFox 46,而不是 MarionetteDriver,我使用了 FirefoxDriver。一切运作良好。现在自动更新到 FireFox 47 后,我遇到了一些问题。
这是驱动程序的设置方式
FirefoxProfile fxProfile = new FirefoxProfile();
fxProfile.setPreference("browser.download.folderList", 2);
fxProfile.setPreference("browser.download.manager.showWhenStarting", false);
fxProfile.setPreference("browser.download.dir", this.workingDir);
fxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
// System.setProperty("webdriver.gecko.driver", "D:/Entwicklung/marionette/wires.exe");
System.setProperty("webdriver.gecko.driver", "D:/Entwicklung/geckodriver/geckodriver.exe");
DesiredCapabilities dc = DesiredCapabilities.firefox();
dc.setPlatform(Platform.WINDOWS);
dc.setCapability(FirefoxDriver.PROFILE, fxProfile);
// dc.setJavascriptEnabled(true);
// dc.setCapability("marionette", true);
this.driver = new MarionetteDriver(dc);
这是JAVA
WebElement field = driver.findElement(By.cssSelector("[id$=\"uploadComp_input\"]"));
field.sendKeys("D:\\Projekte\\Ticket.xml" + Keys.TAB);
由于 FireFox 47 是全新的,所以 WWW 上的文档似乎很少见,希望我能找到可以支持我的人。
谢谢阅读