Skip to content

Commit 32046d6

Browse files
kblokMeir017
authored andcommitted
Tracing.StartAsync without options (#1128)
1 parent 305eaf4 commit 32046d6

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

lib/PuppeteerSharp.Tests/TracingTests/TracingTests.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,15 @@ await Page.Tracing.StartAsync(new TracingOptions
122122
Assert.Equal(trace, buf);
123123
}
124124

125+
[Fact]
126+
public async Task ShouldWorkWithoutOptions()
127+
{
128+
await Page.Tracing.StartAsync();
129+
await Page.GoToAsync(TestConstants.ServerUrl + "/grid.html");
130+
var trace = await Page.Tracing.StopAsync();
131+
Assert.NotNull(trace);
132+
}
133+
125134
[Fact]
126135
public async Task ShouldSupportABufferWithoutAPath()
127136
{

lib/PuppeteerSharp/Tracing.cs

100755100644
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,21 @@ internal Tracing(CDPSession client)
5454
/// </summary>
5555
/// <returns>Start task</returns>
5656
/// <param name="options">Tracing options</param>
57-
public Task StartAsync(TracingOptions options)
57+
public Task StartAsync(TracingOptions options = null)
5858
{
5959
if (_recording)
6060
{
6161
throw new InvalidOperationException("Cannot start recording trace while already recording trace.");
6262
}
6363

64-
var categories = options.Categories ?? _defaultCategories;
64+
var categories = options?.Categories ?? _defaultCategories;
6565

66-
if (options.Screenshots)
66+
if (options?.Screenshots == true)
6767
{
6868
categories.Add("disabled-by-default-devtools.screenshot");
6969
}
7070

71-
_path = options.Path;
71+
_path = options?.Path;
7272
_recording = true;
7373

7474
return _client.SendAsync("Tracing.start", new TracingStartRequest

0 commit comments

Comments
 (0)