This repository has been archived by the owner on Dec 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Installation
Nick edited this page Jun 7, 2018
·
7 revisions
-
1 - Download latest build from Nuget
-
2 - Create App.config
-
3 - Add following config sections to config
<configSections>
<section name="specFlow" type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow" />
<section name="autofac" type="Autofac.Configuration.SectionHandler, Autofac.Configuration" />
</configSections>
- 4 - Add specFlow parameters to config
<specFlow>
<unitTestProvider name="Unickq.SpecFlow.Selenium" />
<generator allowDebugGeneratedFiles="true" markFeaturesParallelizable="true"/>
<plugins>
<add name="Unickq.SpecFlow.Selenium"/>
</plugins>
</specFlow>
- 5 - Add browser component services to autofac section
<autofac>
<components>
<component name="Chrome" type="OpenQA.Selenium.Chrome.ChromeDriver, WebDriver" service="OpenQA.Selenium.IWebDriver, WebDriver" instance-scope="per-dependency" />
<component name="ChromeIphone" type="Unickq.SpecFlow.Selenium.Local.ChromeDriver, Unickq.SpecFlow.Selenium.SpecFlowPlugin" service="OpenQA.Selenium.IWebDriver, WebDriver" instance-scope="per-dependency">
<parameters>
<parameter name="capabilities">
<dictionary>
<item key="arguments" value="--window-size=395,687" />
<item key="mobileEmulation" value="iPhone 6" />
</dictionary>
</parameter>
</parameters>
</component>
</components>
</autofac>
- 6 - Add @Browser:Chrome to your feature file.
- 7.1 - Get and use IWebDriver instance
ScenarioContext.Get<IWebDriver>("Driver")
from static scenario context.
- 7.2 - Create basic class for step binding classes if you want to use Parallelizable attributes in tests.
public class SeleniumHelperBinding
{
protected readonly ScenarioContext ScenarioContext;
protected readonly IWebDriver Browser;
protected SeleniumHelperBinding(ScenarioContext scenarioContext)
{
if (scenarioContext == null) throw new ArgumentNullException("scenarioContext");
ScenarioContext = scenarioContext;
Browser = scenarioContext.GetWebDriver();
}
}
- 8 - Enjoy 🙋