diff --git a/src/Shared/BrowserTesting/src/ContextInformation.cs b/src/Shared/BrowserTesting/src/ContextInformation.cs index 07cadc4bf0f5..f197dff80c7c 100644 --- a/src/Shared/BrowserTesting/src/ContextInformation.cs +++ b/src/Shared/BrowserTesting/src/ContextInformation.cs @@ -55,10 +55,24 @@ internal BrowserContextOptions ConfigureUniqueHarPath(BrowserContextOptions brow if (browserContextOptions?.RecordHar?.Path != null) { var identifier = Guid.NewGuid().ToString("N"); - browserContextOptions.RecordHar.Path = Path.Combine(browserContextOptions.RecordHar.Path, $"{identifier}.har"); + var harDirectory = Environment.GetEnvironmentVariable("HELIX_WORKITEM_UPLOAD_ROOT"); + if (string.IsNullOrEmpty(harDirectory)) + { + harDirectory = browserContextOptions.RecordHar.Path; + } + browserContextOptions.RecordHar.Path = Path.Combine(harDirectory, $"{identifier}.har"); _harPath = browserContextOptions.RecordHar.Path; } + if (browserContextOptions?.RecordVideo?.Dir != null) + { + var uploadDir = Environment.GetEnvironmentVariable("HELIX_WORKITEM_UPLOAD_ROOT"); + if (!string.IsNullOrEmpty(uploadDir)) + { + browserContextOptions.RecordVideo.Dir = uploadDir; + } + } + return browserContextOptions; } }