Skip to content
This repository was archived by the owner on Dec 8, 2022. It is now read-only.

Commit 204757f

Browse files
committed
Merge branch 'dev'
2 parents 7ba73b5 + dfee36a commit 204757f

20 files changed

+322
-151
lines changed

Unickq.SpecFlow.Selenium.Example/App.config

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
<unitTestProvider name="Unickq.SpecFlow.Selenium" />
1212
<generator allowDebugGeneratedFiles="true" markFeaturesParallelizable="true" />
1313
<plugins>
14-
<add name="Unickq.SpecFlow.Selenium" path="..\Unickq.SpecFlow.Selenium.Plugin\bin\Release" />
14+
<!-- <add name="Unickq.SpecFlow.Selenium"/>-->
15+
<add name="Unickq.SpecFlow.Selenium" path="C:\git\Unickq.SpecFlow.Selenium\Unickq.SpecFlow.Selenium.Example\bin\Debug" />
1516
</plugins>
1617
</specFlow>
1718

@@ -28,13 +29,27 @@
2829

2930
<autofac>
3031
<components>
31-
<component name="IE_local" type="OpenQA.Selenium.IE.InternetExplorerDriver, WebDriver" service="OpenQA.Selenium.IWebDriver, WebDriver" instance-scope="per-dependency">
32-
</component>
33-
<component name="Chrome_local" type="OpenQA.Selenium.Chrome.ChromeDriver, WebDriver" service="OpenQA.Selenium.IWebDriver, WebDriver" instance-scope="per-dependency">
34-
</component>
35-
<component name="Chrome_local2" type="OpenQA.Selenium.Chrome.ChromeDriver, WebDriver" service="OpenQA.Selenium.IWebDriver, WebDriver" instance-scope="per-dependency">
32+
<component name="ChromeDebug" type="Unickq.SpecFlow.Selenium.Local.ChromeDriver, Unickq.SpecFlow.Selenium.SpecFlowPlugin" service="OpenQA.Selenium.IWebDriver, WebDriver" instance-scope="per-dependency">
33+
<parameters>
34+
<parameter name="capabilities">
35+
<dictionary>
36+
<item key="arguments" value="--window-size=1024,1024" />
37+
<!-- <item key="mobileEmulation" value="iPhone 6" />-->
38+
<item key="userProfilePreference1" value="intl.accept_languages=nl" />
39+
<item key="userProfilePreference2" value="download.default_directory=D:\workspace" />
40+
</dictionary>
41+
</parameter>
42+
</parameters>
3643
</component>
37-
<component name="Firefox_local" type="OpenQA.Selenium.Firefox.FirefoxDriver, WebDriver" service="OpenQA.Selenium.IWebDriver, WebDriver" instance-scope="per-dependency">
44+
45+
<component name="FirefoxDebug" type="Unickq.SpecFlow.Selenium.Local.FirefoxDriver, Unickq.SpecFlow.Selenium.SpecFlowPlugin" service="OpenQA.Selenium.IWebDriver, WebDriver" instance-scope="per-dependency">
46+
<parameters>
47+
<parameter name="capabilities">
48+
<dictionary>
49+
<item key="capabilities" value="acceptInsecureCerts=true" />
50+
</dictionary>
51+
</parameter>
52+
</parameters>
3853
</component>
3954

4055
<component name="RemoteChrome" type="Unickq.SpecFlow.Selenium.WebDriverGrid.RemoteWebDriver, Unickq.SpecFlow.Selenium.SpecFlowPlugin" service="OpenQA.Selenium.IWebDriver, WebDriver" instance-scope="per-dependency">
@@ -105,6 +120,10 @@
105120
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
106121
<bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
107122
</dependentAssembly>
123+
<dependentAssembly>
124+
<assemblyIdentity name="nunit.framework" publicKeyToken="2638cd05610744eb" culture="neutral" />
125+
<bindingRedirect oldVersion="0.0.0.0-3.9.0.0" newVersion="3.9.0.0" />
126+
</dependentAssembly>
108127
</assemblyBinding>
109128
</runtime>
110129

Unickq.SpecFlow.Selenium.Example/Features/F1.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#@Browser:RemoteChrome
44
#@Browser:Cbt_Win10_Chrome
5-
@Browser:Firefox_local
5+
@Browser:ChromeDebug
66
#@Browser:BrowserStack_Win10_Chrome
77
#@Browser:TestingBot_ElCapitan_Safari
88
#@Browser:SauceLabs_Win7_Firefox

Unickq.SpecFlow.Selenium.Example/Features/F1.feature.cs

Lines changed: 3 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Unickq.SpecFlow.Selenium.Example/Features/F2.feature

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Feature: f2
22

3-
@Browser:Chrome_local
4-
@Browser:Chrome_local2
3+
#@Browser:Chrome_local
4+
#@Browser:Chrome_local2
55
#@Browser:Firefox_local
66
#@Browser:BrowserStack_Win10_Chrome
77
#@Browser:Cbt_Win10_Chrome
@@ -10,6 +10,9 @@
1010
#@GoogleTranslate:FR
1111
#@GoogleTranslate:DE
1212
#@GoogleTranslate:UK
13+
14+
@Browser:ChromeDebug
15+
@Browser:FirefoxDebug
1316
Scenario Outline: Check website title
1417
Given I have opened <URL>
1518
Then the title should contain '<string>'

Unickq.SpecFlow.Selenium.Example/Features/F2.feature.cs

Lines changed: 4 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Unickq.SpecFlow.Selenium.Example/Unickq.SpecFlow.Selenium.Example.csproj

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,17 @@
5050
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
5151
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
5252
</Reference>
53-
<Reference Include="nunit.framework, Version=3.8.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
54-
<HintPath>..\packages\NUnit.3.8.1\lib\net45\nunit.framework.dll</HintPath>
53+
<Reference Include="nunit.framework, Version=3.9.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
54+
<HintPath>..\packages\NUnit.3.9.0\lib\net45\nunit.framework.dll</HintPath>
5555
</Reference>
5656
<Reference Include="System" />
57+
<Reference Include="System.Configuration" />
5758
<Reference Include="System.Drawing" />
5859
<Reference Include="TechTalk.SpecFlow, Version=2.2.0.0, Culture=neutral, PublicKeyToken=0778194805d6db41, processorArchitecture=MSIL">
5960
<HintPath>..\packages\SpecFlow.2.2.1\lib\net45\TechTalk.SpecFlow.dll</HintPath>
6061
</Reference>
61-
<Reference Include="WebDriver, Version=3.6.0.0, Culture=neutral, processorArchitecture=MSIL">
62-
<HintPath>..\packages\Selenium.WebDriver.3.6.0\lib\net45\WebDriver.dll</HintPath>
62+
<Reference Include="WebDriver, Version=3.7.0.0, Culture=neutral, processorArchitecture=MSIL">
63+
<HintPath>..\packages\Selenium.WebDriver.3.7.0\lib\net45\WebDriver.dll</HintPath>
6364
</Reference>
6465
</ItemGroup>
6566
<Choose>
@@ -85,7 +86,9 @@
8586
<Compile Include="Properties\AssemblyInfo.cs" />
8687
</ItemGroup>
8788
<ItemGroup>
88-
<None Include="App.config" />
89+
<None Include="App.config">
90+
<SubType>Designer</SubType>
91+
</None>
8992
<None Include="Features\F1.feature">
9093
<Generator>SpecFlowSingleFileGenerator</Generator>
9194
<LastGenOutput>F1.feature.cs</LastGenOutput>
@@ -97,9 +100,9 @@
97100
<None Include="packages.config" />
98101
</ItemGroup>
99102
<ItemGroup>
100-
<ProjectReference Include="..\Unickq.SpecFlow.Selenium.Plugin\Unickq.SpecFlow.Selenium.Plugin.csproj">
103+
<ProjectReference Include="..\Unickq.SpecFlow.Selenium.Plugin\Unickq.SpecFlow.Selenium.SpecFlowPlugin.csproj">
101104
<Project>{8b277e9f-1fdb-4d30-944b-a8c17308f62b}</Project>
102-
<Name>Unickq.SpecFlow.Selenium.Plugin</Name>
105+
<Name>Unickq.SpecFlow.Selenium.SpecFlowPlugin</Name>
103106
</ProjectReference>
104107
</ItemGroup>
105108
<Choose>
@@ -122,15 +125,15 @@
122125
</Choose>
123126
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
124127
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
125-
<Import Project="..\packages\Selenium.WebDriver.ChromeDriver.2.32.0\build\Selenium.WebDriver.ChromeDriver.targets" Condition="Exists('..\packages\Selenium.WebDriver.ChromeDriver.2.32.0\build\Selenium.WebDriver.ChromeDriver.targets')" />
126128
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
127129
<PropertyGroup>
128130
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
129131
</PropertyGroup>
130-
<Error Condition="!Exists('..\packages\Selenium.WebDriver.ChromeDriver.2.32.0\build\Selenium.WebDriver.ChromeDriver.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Selenium.WebDriver.ChromeDriver.2.32.0\build\Selenium.WebDriver.ChromeDriver.targets'))" />
131-
<Error Condition="!Exists('..\packages\Selenium.Firefox.WebDriver.0.19.0\build\Selenium.Firefox.WebDriver.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Selenium.Firefox.WebDriver.0.19.0\build\Selenium.Firefox.WebDriver.targets'))" />
132+
<Error Condition="!Exists('..\packages\Selenium.Firefox.WebDriver.0.19.1\build\Selenium.Firefox.WebDriver.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Selenium.Firefox.WebDriver.0.19.1\build\Selenium.Firefox.WebDriver.targets'))" />
133+
<Error Condition="!Exists('..\packages\Selenium.WebDriver.ChromeDriver.2.33.0\build\Selenium.WebDriver.ChromeDriver.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Selenium.WebDriver.ChromeDriver.2.33.0\build\Selenium.WebDriver.ChromeDriver.targets'))" />
132134
</Target>
133-
<Import Project="..\packages\Selenium.Firefox.WebDriver.0.19.0\build\Selenium.Firefox.WebDriver.targets" Condition="Exists('..\packages\Selenium.Firefox.WebDriver.0.19.0\build\Selenium.Firefox.WebDriver.targets')" />
135+
<Import Project="..\packages\Selenium.Firefox.WebDriver.0.19.1\build\Selenium.Firefox.WebDriver.targets" Condition="Exists('..\packages\Selenium.Firefox.WebDriver.0.19.1\build\Selenium.Firefox.WebDriver.targets')" />
136+
<Import Project="..\packages\Selenium.WebDriver.ChromeDriver.2.33.0\build\Selenium.WebDriver.ChromeDriver.targets" Condition="Exists('..\packages\Selenium.WebDriver.ChromeDriver.2.33.0\build\Selenium.WebDriver.ChromeDriver.targets')" />
134137
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
135138
Other similar extension points exist, see Microsoft.Common.targets.
136139
<Target Name="BeforeBuild">

Unickq.SpecFlow.Selenium.Example/packages.config

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
<package id="Autofac" version="3.3.1" targetFramework="net452" />
44
<package id="Autofac.Configuration" version="3.3.0" targetFramework="net452" />
55
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net452" />
6-
<package id="NUnit" version="3.8.1" targetFramework="net46" />
7-
<package id="Selenium.Firefox.WebDriver" version="0.19.0" targetFramework="net46" />
8-
<package id="Selenium.WebDriver" version="3.6.0" targetFramework="net46" />
9-
<package id="Selenium.WebDriver.ChromeDriver" version="2.32.0" targetFramework="net46" />
6+
<package id="NUnit" version="3.9.0" targetFramework="net46" />
7+
<package id="Selenium.Firefox.WebDriver" version="0.19.1" targetFramework="net46" />
8+
<package id="Selenium.WebDriver" version="3.7.0" targetFramework="net46" />
9+
<package id="Selenium.WebDriver.ChromeDriver" version="2.33.0" targetFramework="net46" />
1010
<package id="SpecFlow" version="2.2.1" targetFramework="net46" />
1111
</packages>

Unickq.SpecFlow.Selenium.Plugin/Extensions.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using OpenQA.Selenium;
1+
using System;
2+
using OpenQA.Selenium;
23
using TechTalk.SpecFlow;
34

45
namespace Unickq.SpecFlow.Selenium
@@ -16,5 +17,15 @@ public static IWebDriver GetWebDriver(this ScenarioContext scenarioContext)
1617
}
1718
throw new SpecFlowException("Driver is not present in ScenarioContext");
1819
}
20+
21+
public static string[] ParseWithDelimiter(string input, char splitter = '=')
22+
{
23+
var prms = input.Split(splitter);
24+
if (prms.Length != 2)
25+
{
26+
throw new ArgumentException($"Preference count doesn't equal to 2. Please use '{splitter}' delimiter");
27+
}
28+
return new[] { prms[0], prms[1] };
29+
}
1930
}
2031
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using OpenQA.Selenium.Chrome;
4+
5+
namespace Unickq.SpecFlow.Selenium.Local
6+
{
7+
public class ChromeDriver : OpenQA.Selenium.Chrome.ChromeDriver
8+
{
9+
private static ChromeOptions SetOptions(Dictionary<string, object> capabilities)
10+
{
11+
var options = new ChromeOptions();
12+
foreach (var cap in capabilities)
13+
{
14+
if (cap.Key.Equals("MobileEmulation", StringComparison.OrdinalIgnoreCase))
15+
{
16+
options.EnableMobileEmulation(cap.Value.ToString());
17+
}
18+
else if (cap.Key.Equals("Arguments", StringComparison.OrdinalIgnoreCase))
19+
{
20+
options.AddArguments(cap.Value.ToString().Split(';'));
21+
}
22+
else if (cap.Key.Equals("Extensions", StringComparison.OrdinalIgnoreCase))
23+
{
24+
options.AddExtensions(cap.Value.ToString().Split(';'));
25+
}
26+
else if (cap.Key.StartsWith("UserProfilePreference", StringComparison.OrdinalIgnoreCase))
27+
{
28+
var args = Extensions.ParseWithDelimiter(cap.Value.ToString());
29+
options.AddUserProfilePreference(args[0], args[1]);
30+
}
31+
else if (cap.Key.Equals("BinaryLocation", StringComparison.OrdinalIgnoreCase))
32+
{
33+
options.BinaryLocation = cap.Value.ToString();
34+
}
35+
else if (cap.Key.Equals("AcceptInsecureCertificates", StringComparison.OrdinalIgnoreCase))
36+
{
37+
options.AcceptInsecureCertificates = true;
38+
}
39+
else if (cap.Key.StartsWith("Capability", StringComparison.OrdinalIgnoreCase))
40+
{
41+
var args = Extensions.ParseWithDelimiter(cap.Value.ToString());
42+
options.AddAdditionalCapability(args[0], args[1]);
43+
}
44+
}
45+
return options;
46+
}
47+
48+
public ChromeDriver(Dictionary<string, object> capabilities) : base(SetOptions(capabilities))
49+
{
50+
}
51+
}
52+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using OpenQA.Selenium.Edge;
4+
5+
namespace Unickq.SpecFlow.Selenium.Local
6+
{
7+
public class EdgeDriver : OpenQA.Selenium.Edge.EdgeDriver
8+
{
9+
public EdgeDriver(Dictionary<string, object> capabilities) : base(SetOptions(capabilities))
10+
{
11+
}
12+
13+
private static EdgeOptions SetOptions(Dictionary<string, object> capabilities)
14+
{
15+
var options = new EdgeOptions();
16+
foreach (var cap in capabilities)
17+
{
18+
if (cap.Key.StartsWith("Capability", StringComparison.OrdinalIgnoreCase))
19+
{
20+
var args = Extensions.ParseWithDelimiter(cap.Value.ToString());
21+
options.AddAdditionalCapability(args[0], args[1]);
22+
}
23+
}
24+
return options;
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)