简体   繁体   中英

Using Baseclass.Contrib.SpecFlow.Selenium.NUnit to run tests in @Browser:Firefox (C#/Specflow)

I'm currently working on running my Specflow tests in multiple browsers using Baseclass.Contrib.SpecFlow and the @Browser tags.

My test:

@Browser:IE

@Browser:Chrome

@Browser:Firefox

Scenario Outline: Add Two Numbers
...

...

This works GREAT with @Browser:Chrome and @Browser:IE after installing those browser drivers. Unfortunately, it does not work with @Browser:Firefox , which I believe it should since Selenium has the Firefox driver by default.

The error message I get is an Exception from Autofac.Core.DependencyResolutionException:

An exception was thrown while invoking the constructor 'Void .ctor()' on type 'FirefoxDriver'. ---> The system cannot find the file specified

After digging around in the Exception messages, I can't find what file it tries and fails to find.

I tried installing an external Firefox browser driver (Marionette), but that did not work either.

My config:

<autofac>
    <components>
        <component name="IE" type="OpenQA.Selenium.IE.InternetExplorerDriver, WebDriver" service="OpenQA.Selenium.IWebDriver, WebDriver" instance-scope="per-dependency">
        </component>
        <component name="Chrome" type="OpenQA.Selenium.Chrome.ChromeDriver, WebDriver" service="OpenQA.Selenium.IWebDriver, WebDriver" instance-scope="per-dependency">
        </component>
        <component name="Firefox" type="OpenQA.Selenium.Firefox.FirefoxDriver, WebDriver" service="OpenQA.Selenium.IWebDriver, WebDriver" instance-scope="per-dependency">
        </component>

        <!-- Example of using an injected RemoteDriver:
        <component
            name="IE"
            type="Baseclass.Contrib.SpecFlow.Selenium.NUnit.RemoteWebDriver, Baseclass.Contrib.SpecFlow.Selenium.NUnit.SpecFlowPlugin"
            service="OpenQA.Selenium.IWebDriver, WebDriver"
            instance-scope="per-dependency">
            <parameters>
                <parameter name="url" value="http://127.0.0.1:4444/wd/hub" />
                <parameter name="browser" value="InternetExplorer">
                </parameter>
            </parameters>
        </component>
        -->

      </components>

Any idea about how to get this working?

Few other discussions on using Baseclass.Contrib.SpecFlow:

I had this same problem today. I updated the Selenium WebDriver NuGet package and now it works for me. Give that a try. Maybe it'll fix it for you too.

I rewrote Baseclass.Contrib.SpecFlow.Selenium.NUnit for 2.1 support.

New codebase, @ignore tag support for nunit3 and several testing services like BrowserStack, SauceLabs, TestingBot. Check it out

I've created a new SpecFlow plugin (inspired by Baseclass.Contrib.SpecFlow.Selenium.NUnit - thanks unickq).

The details can be found below, the plugin aims to target different variants (such as browsers - but flexible for any use) by using tags such as:

@Browser:Chrome
@Browser:IE
Scenario: A scenario title

This supports SpecFlow 2.4 as well as v3, which means core too. It also supports MsTest, NUnit and xUnit.

https://github.com/TotalTest/SpecFlow.Contrib.Variants

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