我正在尝试添加firefox配置文件和功能,但在创建新的firefox实例时遇到异常。 我知道新的selenium版本使用gecko驱动程序作为firefox驱动程序,firefox版本> 47.0。 但是驱动程序是否支持firefox配置文件? 您可以在下面找到使用过的功能,属性和堆栈跟踪。 Selenium版本:3.4.0。 FireFox版本:> 47.0。
设置功能
case FIREFOX:
FirefoxProfile fp = new FirefoxProfile();
fp.setPreference("browser.download.dir",
System.getProperty("user.dir") + "\\resources\\downloads");
fp.setPreference("browser.download.folderList", 2);
fp.setPreference("browser.download.manager.showWhenStarting", false);
webCapabilities = DesiredCapabilities.firefox();
webCapabilities.setCapability(FirefoxDriver.PROFILE, fp);
创建驱动程序:
case FIREFOX:
System.setProperty("webdriver.gecko.driver", System.getProperty("user.dir") + "//resources//drivers//geckodriver.exe");
return new FirefoxDriver(desiredCapabilities);
堆栈跟踪
> org.openqa.selenium.SessionNotCreatedException: Unable to find a matching
set of capabilities
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'NAEL', ip: '10.0.0.2', os.name: 'Windows 10', os.arch:
'amd64', os.version: '10.0', java.version: '1.8.0_111'
Driver info: driver.version: Driver
remote stacktrace: stack backtrace:
0: 0x4bb74f - <no info>
1: 0x4bbea9 - <no info>
2: 0x43df94 - <no info>
3: 0x447acf - <no info>
4: 0x4203e1 - <no info>
5: 0x407dc7 - <no info>
6: 0x6d95b9 - <no info>
7: 0x4173a7 - <no info>
8: 0x6d38b3 - <no info>
9: 0x7ffe20e72774 - BaseThreadInitThunk
at cucumber.api.testng.TestNGCucumberRunner.runCucumber(TestNGCucumberRunner.java:69)
at cucumber.api.testng.AbstractTestNGCucumberTests.feature(AbstractTestNGCucumberTests.java:21)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:104)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:645)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:851)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1177)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
at org.testng.TestRunner.privateRun(TestRunner.java:756)
at org.testng.TestRunner.run(TestRunner.java:610)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:387)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:382)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340)
at org.testng.SuiteRunner.run(SuiteRunner.java:289)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1293)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1218)
at org.testng.TestNG.runSuites(TestNG.java:1133)
at org.testng.TestNG.run(TestNG.java:1104)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:236)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:81)