Skip to content

Commit

Permalink
Check Name
Browse files Browse the repository at this point in the history
  • Loading branch information
FriggaHel committed Mar 22, 2024
1 parent c0376e1 commit 67c59a6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion visual-dotnet/SauceLabs.Visual/VisualCheckOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class VisualCheckOptions
public IWebElement[]? IgnoreElements { get; set; }
public bool? CaptureDom { get; set; }

public string? ClassName { get; set; }
public string? SuiteName { get; set; }
public string? TestName { get; set; }
}
}
10 changes: 5 additions & 5 deletions visual-dotnet/SauceLabs.Visual/VisualClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class VisualClient : IDisposable
public bool CaptureDom { get; set; } = false;
private readonly ResiliencePipeline _retryPipeline;

private string? _previousTestClass = null;
private string? _previousSuiteName = null;

/// <summary>
/// Creates a new instance of <c>VisualClient</c>
Expand Down Expand Up @@ -231,13 +231,13 @@ public Task<string> VisualCheck(string name, VisualCheckOptions? options = null,
[CallerMemberName] string callerMemberName = "")
{
options ??= new VisualCheckOptions();
if (!string.IsNullOrEmpty(callerMemberName) && (string.IsNullOrEmpty(options.ClassName) || string.IsNullOrEmpty(options.TestName)))
if (!string.IsNullOrEmpty(callerMemberName) && (string.IsNullOrEmpty(options.SuiteName) || string.IsNullOrEmpty(options.TestName)))
{
var stack = new StackTrace();
var frame = stack.GetFrames()?.FirstOrDefault(f => f.GetMethod().Name == callerMemberName);
options.ClassName ??= frame?.GetMethod().DeclaringType?.FullName ?? _previousTestClass;
options.SuiteName ??= frame?.GetMethod().DeclaringType?.FullName ?? _previousSuiteName;
options.TestName ??= callerMemberName;
_previousTestClass = options.ClassName;
_previousSuiteName = options.SuiteName;
}
return VisualCheckAsync(name, options);
}
Expand All @@ -257,7 +257,7 @@ private async Task<string> VisualCheckAsync(string name, VisualCheckOptions opti
sessionId: _sessionId,
sessionMetadata: _sessionMetadataBlob ?? "",
captureDom: options.CaptureDom ?? CaptureDom,
suiteName: options.ClassName,
suiteName: options.SuiteName,
testName: options.TestName
))).EnsureValidResponse();
result.Result.Diffs.Nodes.ToList().ForEach(d => _screenshotIds.Add(d.Id));
Expand Down

0 comments on commit 67c59a6

Please sign in to comment.