diff --git a/dotnet/private/dotnet_nunit_test_suite.bzl b/dotnet/private/dotnet_nunit_test_suite.bzl index 346174fda35fc..a4e80d5486a90 100644 --- a/dotnet/private/dotnet_nunit_test_suite.bzl +++ b/dotnet/private/dotnet_nunit_test_suite.bzl @@ -107,6 +107,10 @@ def _is_test(src, test_suffixes): return True return False +_NUNIT_ARGS = [ + "--workers=1", # Bazel tests share a single driver instance; prevent NUnit parallelism +] + def dotnet_nunit_test_suite( name, srcs, @@ -162,7 +166,7 @@ def dotnet_nunit_test_suite( srcs = lib_srcs + [src] + ["@rules_dotnet//dotnet/private/rules/common/nunit:shim.cs"], deps = deps + extra_deps, target_frameworks = target_frameworks, - args = _BROWSERS[browser]["args"] + _HEADLESS_ARGS, + args = _NUNIT_ARGS + _BROWSERS[browser]["args"] + _HEADLESS_ARGS, data = data + _BROWSERS[browser]["data"], tags = tags + [browser] + COMMON_TAGS + _BROWSERS[browser]["tags"], size = size, diff --git a/dotnet/test/common/BiDi/WebExtension/WebExtensionTest.cs b/dotnet/test/common/BiDi/WebExtension/WebExtensionTest.cs index 21569d40ea034..5f33a02720a50 100644 --- a/dotnet/test/common/BiDi/WebExtension/WebExtensionTest.cs +++ b/dotnet/test/common/BiDi/WebExtension/WebExtensionTest.cs @@ -88,7 +88,16 @@ private static string LocateRelativePath(string path) { try { - return Bazel.Runfiles.Create().Rlocation($"_main/{path}"); + var runfiles = Bazel.Runfiles.Create(); + string resolved = runfiles.Rlocation($"_main/{path}"); + if (!string.IsNullOrEmpty(resolved)) + { + return resolved; + } + + // For directories, locate a file inside and get parent (runfiles manifest only lists files) + string manifestPath = runfiles.Rlocation($"_main/{path}/manifest.json"); + return Path.GetDirectoryName(manifestPath) ?? Path.GetFullPath(path); } catch (FileNotFoundException) { diff --git a/dotnet/test/common/WebElementTest.cs b/dotnet/test/common/WebElementTest.cs index e8c930196b021..93c27dc3537ad 100644 --- a/dotnet/test/common/WebElementTest.cs +++ b/dotnet/test/common/WebElementTest.cs @@ -142,7 +142,12 @@ public void ShouldSubmitElement() IWebElement submit = driver.FindElement(By.Id("submittingButton")); submit.Submit(); - Assert.That(driver.Url, Does.StartWith(resultPage)); + Assert.That( + () => + WaitFor( + () => driver.Url.StartsWith(resultPage), + "We are not redirected to the resultPage after submitting web element"), + Throws.Nothing); } [Test] diff --git a/dotnet/test/firefox/BUILD.bazel b/dotnet/test/firefox/BUILD.bazel index a5ac213d8ca10..37cfbc3da81e7 100644 --- a/dotnet/test/firefox/BUILD.bazel +++ b/dotnet/test/firefox/BUILD.bazel @@ -23,5 +23,6 @@ dotnet_nunit_test_suite( "//dotnet/src/webdriver:webdriver-net8.0", "//dotnet/test/common:fixtures", nuget_package("NUnit"), + nuget_package("Runfiles"), ], ) diff --git a/dotnet/test/firefox/FirefoxDriverTest.cs b/dotnet/test/firefox/FirefoxDriverTest.cs index 83e1ecd8ec560..131d7cd5a8ac8 100644 --- a/dotnet/test/firefox/FirefoxDriverTest.cs +++ b/dotnet/test/firefox/FirefoxDriverTest.cs @@ -333,6 +333,7 @@ public void ShouldInstallAndUninstallSignedZipAddon() } [Test] + [IgnorePlatform("windows", "Signed directory add-on install fails on Windows (ERROR_CORRUPT_FILE).")] public void ShouldInstallAndUninstallSignedDirAddon() { FirefoxDriver firefoxDriver = driver as FirefoxDriver; @@ -372,9 +373,18 @@ public void ShouldInstallAndUninstallUnSignedDirAddon() private string GetPath(string name) { - string sCurrentDirectory = AppDomain.CurrentDomain.BaseDirectory; - string sFile = Path.Combine(sCurrentDirectory, "../../../../common/extensions/" + name); - return Path.GetFullPath(sFile); + try + { + // For directories, locate a file inside and get parent (runfiles manifest only lists files) + string path = Bazel.Runfiles.Create().Rlocation($"_main/common/extensions/{name}/manifest.json"); + return Path.GetDirectoryName(path); + } + catch (FileNotFoundException) + { + string sCurrentDirectory = AppDomain.CurrentDomain.BaseDirectory; + string sFile = Path.Combine(sCurrentDirectory, "../../../../common/extensions/" + name); + return Path.GetFullPath(sFile); + } } private static bool PlatformHasNativeEvents()