Skip to content

Commit

Permalink
[dotnet] Allow to run tests w/o pinned browsers
Browse files Browse the repository at this point in the history
  • Loading branch information
p0deje committed May 15, 2024
1 parent 03f626f commit 6978ea8
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
1 change: 1 addition & 0 deletions common/manager/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package(
default_visibility = [
"//dotnet/src/webdriver:__pkg__",
"//dotnet/test/common:__pkg__",
"//java/src/org/openqa/selenium/manager:__pkg__",
"//javascript/node/selenium-webdriver:__pkg__",
"//py:__pkg__",
Expand Down
3 changes: 3 additions & 0 deletions dotnet/src/webdriver/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,21 @@ copy_file(
name = "manager-linux",
src = "//common/manager:selenium-manager-linux",
out = "manager/linux/selenium-manager",
visibility = ["//dotnet/test/common:__pkg__"],
)

copy_file(
name = "manager-macos",
src = "//common/manager:selenium-manager-macos",
out = "manager/macos/selenium-manager",
visibility = ["//dotnet/test/common:__pkg__"],
)

copy_file(
name = "manager-windows",
src = "//common/manager:selenium-manager-windows",
out = "manager/windows/selenium-manager.exe",
visibility = ["//dotnet/test/common:__pkg__"],
)

nuget_pack(
Expand Down
12 changes: 12 additions & 0 deletions dotnet/test/common/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ filegroup(
data = [
"appconfig.json",
"//common/src/web",
"//dotnet/src/webdriver:manager-linux",
"//dotnet/src/webdriver:manager-macos",
"//dotnet/src/webdriver:manager-windows",
"//java/test/org/openqa/selenium/environment:appserver",
"//java/test/org/openqa/selenium/environment:keystore",
"//javascript/atoms",
Expand All @@ -39,6 +42,9 @@ csharp_library(
"**/*Tests.cs",
],
),
data = [
"//common/manager:selenium-manager-macos",
],
target_frameworks = ["net7.0"],
targeting_packs = [
framework("nuget", "Microsoft.NETCore.App.Ref"),
Expand All @@ -54,6 +60,12 @@ csharp_library(
],
)

# copy_file(
# name = "manager-macos",
# src = "//common/manager:selenium-manager-macos",
# out = "manager/macos/selenium-manager",
# )

dotnet_nunit_test_suite(
name = "AllTests",
size = "large",
Expand Down
27 changes: 26 additions & 1 deletion dotnet/test/common/Environment/EnvironmentManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;

namespace OpenQA.Selenium.Environment
{
Expand All @@ -23,9 +24,9 @@ public class EnvironmentManager
private EnvironmentManager()
{
string dataFilePath;
var runfiles = Runfiles.Create();
try
{
var runfiles = Runfiles.Create();
dataFilePath = runfiles.Rlocation("_main/dotnet/test/common/appconfig.json");
}
catch (FileNotFoundException)
Expand Down Expand Up @@ -138,6 +139,30 @@ private EnvironmentManager()
projectRoot += "/_main";
}

// Find selenium-manager binary.
try
{
string managerFilePath = "";
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
managerFilePath = runfiles.Rlocation("_main/dotnet/src/webdriver/manager/windows/selenium-manager.exe");
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
managerFilePath = runfiles.Rlocation("_main/dotnet/src/webdriver/manager/linux/selenium-manager");
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
managerFilePath = runfiles.Rlocation("_main/dotnet/src/webdriver/manager/macos/selenium-manager");
}

System.Environment.SetEnvironmentVariable("SE_MANAGER_PATH", managerFilePath);
}
catch (FileNotFoundException)
{
// Use the default one.
}

webServer = new TestWebServer(projectRoot, webServerConfig);
bool autoStartRemoteServer = false;
if (browser == Browser.Remote)
Expand Down

0 comments on commit 6978ea8

Please sign in to comment.