简体   繁体   English

org.openqa.selenium.SessionNotCreatedException:在尝试使用Selenium v​​3.8.1启动Firefox时找不到匹配的功能集

[英]org.openqa.selenium.SessionNotCreatedException: Unable to find a matching set of capabilities while trying to launch Firefox with Selenium v3.8.1

I am not able to launch Firefox browser using geckodriver in Selenium 3.8.1 我无法在Selenium 3.8.1中使用geckodriver启动Firefox浏览器

This is my code 这是我的代码

public class LoginTest {
    @SuppressWarnings("deprecation")
    @Test
    public static void logintest() {
        System.setProperty("webdriver.gecko.driver",
            "C:\\Users\\abc\\Downloads\\geckodriver.exe");
        DesiredCapabilities dc = DesiredCapabilities.firefox();
        dc.setCapability("marionnete", true);
        constants.driver = new FirefoxDriver(dc);
        constants.driver.get("https://www.amazon.in");
        constants.driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        constants.driver.manage().window().maximize();
    }

I am not able to understand why it is not working and always giving an exception 我无法理解为什么它无法正常工作并总是给出异常

org.openqa.selenium.SessionNotCreatedException`: Unable to find a matching set of capabilities
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12- 01T18:33:54.468Z'<br>
System info: host: 'ABC-VAIO', ip: '192.168.1.209', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_161'<br>
Driver info: driver.version: FirefoxDriver

You should add capabilities for firefox Please modify your code as follows : 您应该为firefox添加功能。请按以下步骤修改代码:

System.setProperty("webdriver.gecko.driver", "C:\\Selenium\\geckodriver.exe");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities = DesiredCapabilities.firefox();
capabilities.setBrowserName("firefox");
capabilities.setVersion("your firefox version");
capabilities.setPlatform(Platform.WINDOWS);
capabilities.setCapability("marionette", false);
WebDriver driver = new FirefoxDriver(capabilities);
driver.get("https://www.amazon.in");

This error message... 此错误消息...

org.openqa.selenium.SessionNotCreatedException: Unable to find a matching set of capabilities

...implies that the FirefoxDriver didn't find a matching set of capability while initiating a new WebBrowser session. ...表示FirefoxDriver在启动新的WebBrowser会话时找不到匹配的功能集。

You are using Selenium Client v3.8.1 but the Release Notes of Selenium Client v3.7.0 clearly states that : 您正在使用Selenium Client v3.8.1,Selenium Client v3.7.0发行说明明确指出:

* Migrated from using `DesiredCapabilities` to either
  `MutableCapabilities` or (preferably) `ImmutableCapabilities`.

So, you have to use the merge() method from MutableCapabilities Class to add the capabilities within an instance of FirefoxOptions and pass the FirefoxOptions object while initializing the Firefox Browser as follows : 所以,你必须使用merge()从法MutableCapabilities级到的实例中添加功能FirefoxOptions ,并通过在初始化Firefox浏览器如下FirefoxOptions对象:

System.setProperty("webdriver.gecko.driver", "C:\\Users\\abc\\Downloads\\geckodriver.exe");
DesiredCapabilities dc = DesiredCapabilities.firefox();
dc.setCapability("marionnete", true);
FirefoxOptions opt = new FirefoxOptions();
opt.merge(dc);
constants.driver = new FirefoxDriver(opt);
constants.driver.get("https://www.amazon.in");

暂无
暂无

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

相关问题 org.openqa.selenium.SessionNotCreatedException:无法找到匹配的功能集 - org.openqa.selenium.SessionNotCreatedException: Unable to find a matching set of capabilities Selenium(OSX 和 Linux)抛出错误 org.openqa.selenium.SessionNotCreatedException:会话未创建:找不到匹配的功能 - Selenium(OSX and Linux) thowing error org.openqa.selenium.SessionNotCreatedException: session not created: No matching capabilities found org.openqa.selenium.SessionNotCreatedException - org.openqa.selenium.SessionNotCreatedException org.openqa.selenium.SessionNotCreatedException - org.openqa.selenium.SessionNotCreatedException org.openqa.selenium.SessionNotCreatedException:所需功能错误 - org.openqa.selenium.SessionNotCreatedException: desired capabilities error org.openqa.selenium.SessionNotCreatedException:无法通过 Selenium 和 Java 使用 GeckoDriver 和 Firefox 创建会话错误 - org.openqa.selenium.SessionNotCreatedException: Unable to create session error using GeckoDriver and Firefox through Selenium and Java Firefox 驱动程序失败并出现 org.openqa.selenium.SessionNotCreatedException: - Firefox Driver fails with org.openqa.selenium.SessionNotCreatedException: SeleniumError:org.openqa.selenium.SessionNotCreatedException - SeleniumError : org.openqa.selenium.SessionNotCreatedException org.openqa.selenium.SessionNotCreatedException 与 Appium - org.openqa.selenium.SessionNotCreatedException with Appium Appium _org.openqa.selenium.SessionNotCreatedException - Appium _org.openqa.selenium.SessionNotCreatedException
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM