Skip to content

Commit 95c75ae

Browse files
committed
[dotnet] toggle debug logs for tests based on environment variable DEBUG
1 parent 23ab75c commit 95c75ae

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

dotnet/test/common/Environment/EnvironmentManager.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
using System.IO;
2626
using System.Linq;
2727
using System.Runtime.InteropServices;
28+
using OpenQA.Selenium.Internal.Logging;
2829

2930
namespace OpenQA.Selenium.Environment
3031
{
@@ -60,8 +61,13 @@ private EnvironmentManager()
6061

6162
string activeDriverConfig = System.Environment.GetEnvironmentVariable("ACTIVE_DRIVER_CONFIG") ?? TestContext.Parameters.Get("ActiveDriverConfig", env.ActiveDriverConfig);
6263
string driverServiceLocation = System.Environment.GetEnvironmentVariable("DRIVER_SERVICE_LOCATION") ?? TestContext.Parameters.Get("DriverServiceLocation", env.DriverServiceLocation);
63-
6464
string browserLocation = System.Environment.GetEnvironmentVariable("BROWSER_LOCATION") ?? TestContext.Parameters.Get("BrowserLocation", string.Empty);
65+
string enableDebugging = System.Environment.GetEnvironmentVariable("DEBUG") ?? TestContext.Parameters.Get("Debug", env.Debug);
66+
67+
if (!string.IsNullOrEmpty(enableDebugging))
68+
{
69+
Log.SetLevel(LogEventLevel.Debug);
70+
}
6571

6672
string activeWebsiteConfig = TestContext.Parameters.Get("ActiveWebsiteConfig", env.ActiveWebsiteConfig);
6773
DriverConfig driverConfig = env.DriverConfigs[activeDriverConfig];

dotnet/test/common/Environment/TestEnvironment.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,8 @@ class TestEnvironment
4848

4949
[JsonProperty]
5050
public TestWebServerConfig TestWebServerConfig { get; set; }
51+
52+
[JsonProperty]
53+
public string Debug { get; set; }
5154
}
5255
}

0 commit comments

Comments
 (0)