Skip to content

Commit 164a4f5

Browse files
authored
Merge pull request #88 from quantori/update-package-versions
Updated packages (including Selenium to 4 version)
2 parents fdf8abe + 1220353 commit 164a4f5

File tree

9 files changed

+45
-41
lines changed

9 files changed

+45
-41
lines changed

Behavioral.Automation.DemoBindings/Behavioral.Automation.DemoBindings.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="Selenium.Support" Version="3.141.0" />
13-
<PackageReference Include="Selenium.WebDriver" Version="3.141.0" />
14-
<PackageReference Include="SpecFlow" Version="3.7.13" />
12+
<PackageReference Include="Selenium.Support" Version="4.1.0" />
13+
<PackageReference Include="Selenium.WebDriver" Version="4.1.0" />
14+
<PackageReference Include="SpecFlow" Version="3.9.40" />
1515
</ItemGroup>
1616

1717
<ItemGroup>

Behavioral.Automation.DemoScenarios/Behavioral.Automation.DemoScenarios.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
13-
<PackageReference Include="SpecFlow" Version="3.7.13" />
14-
<PackageReference Include="SpecFlow.NUnit" Version="3.7.13" />
15-
<PackageReference Include="SpecFlow.Tools.MsBuild.Generation" Version="3.7.13" />
16-
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
12+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
13+
<PackageReference Include="SpecFlow" Version="3.9.40" />
14+
<PackageReference Include="SpecFlow.NUnit" Version="3.9.40" />
15+
<PackageReference Include="SpecFlow.Tools.MsBuild.Generation" Version="3.9.40" />
16+
<PackageReference Include="NUnit3TestAdapter" Version="4.1.0" />
1717
</ItemGroup>
1818

1919
<ItemGroup>

src/Behavioral.Automation.UnitTests/Behavioral.Automation.UnitTests.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Moq" Version="4.14.5" />
11-
<PackageReference Include="nunit" Version="3.13.1" />
12-
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
13-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
10+
<PackageReference Include="Moq" Version="4.16.1" />
11+
<PackageReference Include="nunit" Version="3.13.2" />
12+
<PackageReference Include="NUnit3TestAdapter" Version="4.1.0" />
13+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
1414
</ItemGroup>
1515

1616
<ItemGroup>

src/Behavioral.Automation/Behavioral.Automation.csproj

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ The whole automation code is divided into the following parts:
2222
<ItemGroup>
2323
<PackageReference Include="ExcelDataReader" Version="3.6.0" />
2424
<PackageReference Include="ExcelDataReader.DataSet" Version="3.6.0" />
25-
<PackageReference Include="FluentAssertions" Version="5.10.3" />
26-
<PackageReference Include="JetBrains.Annotations" Version="2020.3.0" />
27-
<PackageReference Include="Microsoft.Extensions.Configuration" Version="5.0.0" />
28-
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="5.0.0" />
29-
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="5.0.0" />
30-
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />
31-
<PackageReference Include="NUnit" Version="3.13.1" />
32-
<PackageReference Include="Selenium.Support" Version="3.141.0" />
33-
<PackageReference Include="Selenium.WebDriver" Version="3.141.0" />
34-
<PackageReference Include="SpecFlow" Version="3.7.13" />
25+
<PackageReference Include="FluentAssertions" Version="6.2.0" />
26+
<PackageReference Include="JetBrains.Annotations" Version="2021.3.0" />
27+
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.0" />
28+
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="6.0.0" />
29+
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="6.0.0" />
30+
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
31+
<PackageReference Include="NUnit" Version="3.13.2" />
32+
<PackageReference Include="Selenium.Support" Version="4.1.0" />
33+
<PackageReference Include="Selenium.WebDriver" Version="4.1.0" />
34+
<PackageReference Include="SpecFlow" Version="3.9.40" />
3535
</ItemGroup>
3636

3737
</Project>

src/Behavioral.Automation/Bindings/ListBinding.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,6 @@ namespace Behavioral.Automation.Bindings
1111
[Binding]
1212
public class ListBinding
1313
{
14-
private readonly IDriverService _driverService;
15-
16-
public ListBinding([NotNull] IDriverService driverService)
17-
{
18-
_driverService = driverService;
19-
}
20-
2114
[Given("(.+?) (has|does not have) the following items:")]
2215
[Then("(.+?) should (have|not have) the following items:")]
2316
public void CheckListHaveItems(IListWrapper list, string behavior, Table table)

src/Behavioral.Automation/FluentAssertions/Assert.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public static void True(bool condition, string message)
8989
if (!condition)
9090
{
9191
TestContext.WriteLine($"\nActual:\n{message}");
92-
NUnit.Framework.Assert.Fail();
92+
NUnit.Framework.Assert.Fail($"Test execution failed: \n{message}");
9393
}
9494
}
9595

src/Behavioral.Automation/Services/BrowserRunner.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
using System;
22
using System.Collections.Generic;
33
using JetBrains.Annotations;
4+
using OpenQA.Selenium;
45
using OpenQA.Selenium.Chrome;
6+
using OpenQA.Selenium.Chromium;
57
using OpenQA.Selenium.Remote;
68

79
namespace Behavioral.Automation.Services
810
{
911
public class BrowserRunner
1012
{
11-
public RemoteWebDriver Driver;
12-
13-
public void OpenBrowser([NotNull] RemoteWebDriver driver)
13+
public IWebDriver Driver;
14+
15+
public void OpenBrowser([NotNull] IWebDriver driver)
1416
{
1517
Driver = driver;
1618
}
@@ -51,7 +53,7 @@ public void OpenChrome(ChromeOptions options = null)
5153
{"behavior", "allow"},
5254
{"downloadPath", downloadPath}
5355
};
54-
driver.ExecuteChromeCommand("Page.setDownloadBehavior", param);
56+
driver.ExecuteCdpCommand("Page.setDownloadBehavior", param);
5557
OpenBrowser(driver);
5658
}
5759

src/Behavioral.Automation/Services/DriverService.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public DriverService([NotNull] IScopeContextManager scopeContextManager, Browser
2626
_browserRunner = browserRunner;
2727
}
2828

29-
public RemoteWebDriver Driver => _browserRunner.Driver;
29+
public IWebDriver Driver => _browserRunner.Driver;
3030

3131
private readonly string SearchAttribute = ConfigServiceBase.SearchAttribute;
3232

@@ -80,13 +80,19 @@ public ReadOnlyCollection<IWebElement> FindElementsByXpath(string path)
8080
return Driver.FindElements(By.XPath(path));
8181
}
8282

83+
public object ExecuteScript(string script, params object[] args)
84+
{
85+
IJavaScriptExecutor js = (IJavaScriptExecutor)Driver;
86+
return js.ExecuteScript(script, args);
87+
}
88+
8389
public void ScrollTo(IWebElement element)
8490
{
8591
var scrollElementIntoMiddle = "var viewPortHeight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);"
8692
+ "var elementTop = arguments[0].getBoundingClientRect().top;"
8793
+ "window.scrollBy(0, elementTop-(viewPortHeight/2));";
8894

89-
Driver.ExecuteScript(scrollElementIntoMiddle, element);
95+
ExecuteScript(scrollElementIntoMiddle, element);
9096
Actions actions = new Actions(Driver);
9197
actions.MoveToElement(element);
9298
actions.Perform();
@@ -130,8 +136,8 @@ private Uri GetUriFromRelativePath(string url)
130136
}
131137

132138
public void RemoveFocusFromActiveElement()
133-
{
134-
Driver.ExecuteScript("document.activeElement.blur()");
139+
{
140+
ExecuteScript("document.activeElement.blur()");
135141
}
136142

137143
public void DebugDumpPage()
@@ -165,13 +171,14 @@ public void ResizeWindow(int Height, int Width)
165171
public string MakeScreenShot()
166172
{
167173
var fileName = Regex.Replace(TestContext.CurrentContext.Test.Name, @"(\\|\"")", string.Empty) + ".png";
168-
Driver.GetScreenshot().SaveAsFile(fileName, ScreenshotImageFormat.Png);
174+
Screenshot screenshot = ((ITakesScreenshot)Driver).GetScreenshot();
175+
screenshot.SaveAsFile(fileName, ScreenshotImageFormat.Png);
169176
return fileName;
170177
}
171178

172179
public void ScrollElementTo(IWebElement element, int offset)
173180
{
174-
Driver.ExecuteScript(@"
181+
ExecuteScript(@"
175182
var element = arguments[0];
176183
var offset = arguments[1];
177184
element.scrollTo({top: offset, behavior: 'smooth'});", element, offset);

src/Behavioral.Automation/Services/IDriverService.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Behavioral.Automation.Services
77
{
88
public interface IDriverService
99
{
10-
RemoteWebDriver Driver { get; }
10+
IWebDriver Driver { get; }
1111

1212
string CurrentUrl { [NotNull] get; }
1313

@@ -26,6 +26,8 @@ public interface IDriverService
2626

2727
ReadOnlyCollection<IWebElement> FindElementsByXpath([NotNull] string path);
2828

29+
object ExecuteScript(string script, params object[] args);
30+
2931
public void Refresh();
3032

3133
void Navigate([NotNull] string url);

0 commit comments

Comments
 (0)