Skip to content

Commit 33b7a1e

Browse files
nvborisenkodiemol
authored andcommitted
[dotnet] Use selenium manager in tests (SeleniumHQ#11871)
* Copy manager binaries to tests output * Use selenium manager implicitly to execute tests * Trigger tests again * Revert "Trigger tests again" This reverts commit 6dde845. * Fix flaky ShouldBeAbleToUploadTheSameFileTwice tests * Remove preinstalled drivers * Remove all known pre-installed drivers * Damn powershell * Print verbose messages while deleting drivers * Return back globalization namespace --------- Co-authored-by: Diego Molina <[email protected]>
1 parent e9c3499 commit 33b7a1e

File tree

5 files changed

+24
-9
lines changed

5 files changed

+24
-9
lines changed

.github/workflows/ci-dotnet.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@ jobs:
3131
include:
3232
- driver: Chrome
3333
browser: chrome
34-
location: C:\SeleniumWebDrivers\ChromeDriver
3534
- driver: Firefox
3635
browser: chrome
37-
location: C:\SeleniumWebDrivers\GeckoDriver
3836
with:
3937
name: Browser Tests (${{ matrix.driver }}, ${{ matrix.framework }})
4038
browser: ${{ matrix.browser }}
@@ -44,6 +42,8 @@ jobs:
4442
run: |
4543
bazel build //dotnet/test/common:${{ matrix.browser }}
4644
$env:ACTIVE_DRIVER_CONFIG = '${{ matrix.driver }}'
47-
$env:DRIVER_SERVICE_LOCATION = '${{ matrix.location }}'
45+
rm "$env:ChromeWebDriver" -r -v
46+
rm "$env:EdgeWebDriver" -r -v
47+
rm "$env:GeckoWebDriver" -r -v
4848
cd dotnet
4949
dotnet test test/common/WebDriver.Common.Tests.csproj --framework ${{ matrix.framework }}

dotnet/src/webdriver/SeleniumManager.cs

+5-3
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@
1616
// limitations under the License.
1717
// </copyright>
1818

19+
using Newtonsoft.Json;
20+
using OpenQA.Selenium.Internal;
1921
using System;
2022
using System.Collections.Generic;
2123
using System.Diagnostics;
22-
using Newtonsoft.Json;
23-
using OpenQA.Selenium.Internal;
2424
using System.Globalization;
25+
using System.Reflection;
2526

2627
#if !NET45 && !NET46 && !NET47
2728
using System.Runtime.InteropServices;
@@ -37,6 +38,7 @@ namespace OpenQA.Selenium
3738
/// </summary>
3839
public static class SeleniumManager
3940
{
41+
private static string basePath = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
4042
private static string binary;
4143

4244
/// <summary>
@@ -140,7 +142,7 @@ private static string Binary
140142
private static string RunCommand(string fileName, string arguments)
141143
{
142144
Process process = new Process();
143-
process.StartInfo.FileName = fileName;
145+
process.StartInfo.FileName = $"{basePath}/{fileName}";
144146
process.StartInfo.Arguments = arguments;
145147
process.StartInfo.UseShellExecute = false;
146148
process.StartInfo.RedirectStandardOutput = true;

dotnet/src/webdriver/build/Selenium.WebDriver.targets

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33

4+
<PropertyGroup>
5+
<Selenium_Manager_BinariesRootPath Condition="$(Selenium_Manager_BinariesRootPath) == ''">$(MSBuildThisFileDirectory)..\manager</Selenium_Manager_BinariesRootPath>
6+
</PropertyGroup>
7+
48
<ItemGroup>
5-
<None Include="$(MSBuildThisFileDirectory)..\manager\linux\selenium-manager">
9+
<None Include="$(Selenium_Manager_BinariesRootPath)\linux\selenium-manager">
610
<Link>selenium-manager\linux\%(Filename)%(Extension)</Link>
711
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
812
<Visible>False</Visible>
913
</None>
1014

11-
<None Include="$(MSBuildThisFileDirectory)..\manager\macos\selenium-manager">
15+
<None Include="$(Selenium_Manager_BinariesRootPath)\macos\selenium-manager">
1216
<Link>selenium-manager\macos\%(Filename)%(Extension)</Link>
1317
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
1418
<Visible>False</Visible>
1519
</None>
1620

17-
<None Include="$(MSBuildThisFileDirectory)..\manager\windows\selenium-manager.exe">
21+
<None Include="$(Selenium_Manager_BinariesRootPath)\windows\selenium-manager.exe">
1822
<Link>selenium-manager\windows\%(Filename)%(Extension)</Link>
1923
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
2024
<Visible>False</Visible>

dotnet/test/common/FormHandlingTests.cs

+3
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,9 @@ public void ShouldBeAbleToUploadTheSameFileTwice()
218218

219219
uploadElement.SendKeys(inputFile.FullName);
220220
uploadElement.Submit();
221+
222+
// Explicitly wait next page to be loaded, Firefox is not handling elements submitting
223+
WaitFor(() => driver.Url.EndsWith("resultPage.html"), "We are not redirected to the resultPage after submitting web element");
221224
}
222225

223226
inputFile.Delete();

dotnet/test/common/WebDriver.Common.Tests.csproj

+6
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,10 @@
6363
<Exec Command="$(ProjectDir)WebDriver.Common.Tests.csproj.prebuild.sh $(ProjectDir)" />
6464
</Target>
6565

66+
<!-- It is automatically imported when Selenium.WebDriver consumed via nuget package -->
67+
<PropertyGroup>
68+
<Selenium_Manager_BinariesRootPath>..\..\..\common\manager</Selenium_Manager_BinariesRootPath>
69+
</PropertyGroup>
70+
<Import Project="..\..\src\webdriver\build\Selenium.WebDriver.targets" />
71+
6672
</Project>

0 commit comments

Comments
 (0)