package?com.selenium.study;
import?org.openqa.selenium.*;
import?org.openqa.selenium.WebDriver;
import?org.openqa.selenium.firefox.*;
public?class?study?{
public?static?void?main(String[]?args)?{
//?TODO?Auto-generated?method?stub
//實例化一個對象Firefox
WebDriver?driver;
System.setProperty("webdriver.gecko.driver",
"C:\\Program?Files\\Mozilla?Firefox\\geckodriver.exe");?//獲取路徑
driver?=?new?FirefoxDriver();
String?testurl="http://www.baidu.com";
driver.get(testurl);
System.out.println(driver.getTitle());
driver.quit();
}
}報錯:1517058193132 geckodriver INFO geckodriver 0.19.11517058193147 geckodriver INFO Listening on 127.0.0.1:28726Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to find a matching set of capabilitiesBuild info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T19:05:32.194Z'System info: host: 'MS-20170227JPSV', ip: '192.168.31.225', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_92'Driver info: driver.version: FirefoxDriverremote stacktrace: stack backtrace:? ?0:? ? ? ? ? ?0x47e934 - <no info>? ?1:? ? ? ? ? ?0x47f0a3 - <no info>? ?2:? ? ? ? ? ?0x442511 - <no info>? ?3:? ? ? ? ? ?0x4436da - <no info>? ?4:? ? ? ? ? ?0x42a890 - <no info>? ?5:? ? ? ? ? ?0x406f5e - <no info>? ?6:? ? ? ? ? ?0x40cfc9 - <no info>? ?7:? ? ? ? ? ?0x6bef19 - <no info>? ?8:? ? ? ? ? ?0x420756 - <no info>? ?9:? ? ? ? ? ?0x6b96e0 - <no info>? 10:? ? ? ? ?0x770059cd - BaseThreadInitThunk 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:423) at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$new$0(W3CHandshakeResponse.java:57) at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$getResponseFunction$2(W3CHandshakeResponse.java:104) at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:123) at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958) at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126) at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498) at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485) at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152) at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464) at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:126) at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:73) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142) at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:219) at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:142) at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:120) at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:98) at com.selenium.study.study.main(study.java:13)
自動測試-selenium啟動Firefox失敗并報錯:無法找到匹配的功能集
angelazhuzhu
2018-01-27 21:08:23