How to use TracingStopChunkOptions method of Microsoft.Playwright.TracingStopChunkOptions class

Best Playwright-dotnet code snippet using Microsoft.Playwright.TracingStopChunkOptions.TracingStopChunkOptions

Run Playwright-dotnet automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

TracingSynchronous.cs

Source: TracingSynchronous.cs Github

copy
1/*
2 * MIT License
3 *
4 * Copyright (c) Evgeny Nazarchuk.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24
25using Microsoft.Playwright;
26
27namespace Playwright.Synchronous;
28
29public static class TracingSynchronous
30{
31    /// <summary>
32    /// <para>Start tracing.</para>
33    /// <code>
34    /// await using var browser = playwright.Chromium.LaunchAsync();<br/>
35    /// await using var context = await browser.NewContextAsync();<br/>
36    /// await context.Tracing.StartAsync(new TracingStartOptions<br/>
37    /// {<br/>
38    ///   Screenshots: true,<br/>
39    ///   Snapshots: true<br/>
40    /// });<br/>
41    /// var page = context.NewPageAsync();<br/>
42    /// await page.GotoAsync("https://playwright.dev");<br/>
43    /// await context.Tracing.StopAsync(new TracingStopOptions<br/>
44    /// {<br/>
45    ///   Path: "trace.zip"<br/>
46    /// });
47    /// </code>
48    /// </summary>
49    /// <param name="options">Call options</param>
50    public static void Start(ITracing tracing, TracingStartOptions? options = default)
51    {
52        tracing.StartAsync(options).GetAwaiter().GetResult();
53    }
54
55    /// <summary>
56    /// <para>
57    /// Start a new trace chunk. If you'd like to record multiple traces on the same <see
58    /// cref="IBrowserContext"/>, use <see cref="ITracing.StartAsync"/> once, and then create
59    /// multiple trace chunks with <see cref="ITracing.StartChunkAsync"/> and <see cref="ITracing.StopChunkAsync"/>.
60    /// </para>
61    /// <code>
62    /// await using var browser = playwright.Chromium.LaunchAsync();<br/>
63    /// await using var context = await browser.NewContextAsync();<br/>
64    /// await context.Tracing.StartAsync(new TracingStartOptions<br/>
65    /// {<br/>
66    ///   Screenshots: true,<br/>
67    ///   Snapshots: true<br/>
68    /// });<br/>
69    /// var page = context.NewPageAsync();<br/>
70    /// await page.GotoAsync("https://playwright.dev");<br/>
71    /// <br/>
72    /// await context.Tracing.StartChunkAsync();<br/>
73    /// await page.ClickAsync("text=Get Started");<br/>
74    /// // Everything between StartChunkAsync and StopChunkAsync will be recorded in the trace.<br/>
75    /// await context.Tracing.StopChunkAsync(new TracingStopChunkOptions<br/>
76    /// {<br/>
77    ///   Path: "trace1.zip"<br/>
78    /// });<br/>
79    /// <br/>
80    /// await context.Tracing.StartChunkAsync();<br/>
81    /// await page.GotoAsync("http://example.com");<br/>
82    /// // Save a second trace file with different actions.<br/>
83    /// await context.Tracing.StopChunkAsync(new TracingStopChunkOptions<br/>
84    /// {<br/>
85    ///   Path: "trace2.zip"<br/>
86    /// });
87    /// </code>
88    /// </summary>
89    /// <param name="options">Call options</param>
90    public static void StartChunk(ITracing tracing, TracingStartChunkOptions? options = default)
91    {
92        tracing.StartChunkAsync(options).GetAwaiter().GetResult();
93    }
94
95    /// <summary><para>Stop tracing.</para></summary>
96    /// <param name="options">Call options</param>
97    public static void Stop(ITracing tracing, TracingStopOptions? options = default)
98    {
99        tracing.StopAsync(options).GetAwaiter().GetResult();
100    }
101
102    /// <summary>
103    /// <para>
104    /// Stop the trace chunk. See <see cref="ITracing.StartChunkAsync"/> for more details
105    /// about multiple trace chunks.
106    /// </para>
107    /// </summary>
108    /// <param name="options">Call options</param>
109    public static void StopChunk(ITracing tracing, TracingStopChunkOptions? options = default)
110    {
111        tracing.StopChunkAsync(options).GetAwaiter().GetResult();
112    }
113}
114
Full Screen

TracingStopChunkOptions.cs

Source: TracingStopChunkOptions.cs Github

copy
1/*
2 * MIT License
3 *
4 * Copyright (c) Microsoft Corporation.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24
25using System;
26using System.Collections.Generic;
27using System.ComponentModel.DataAnnotations;
28using System.Drawing;
29using System.Globalization;
30using System.IO;
31using System.Runtime.Serialization;
32using System.Text.Json;
33using System.Text.Json.Serialization;
34using System.Text.RegularExpressions;
35using System.Threading;
36using System.Threading.Tasks;
37
38#nullable enable
39
40namespace Microsoft.Playwright
41{
42    public class TracingStopChunkOptions
43    {
44        public TracingStopChunkOptions() { }
45
46        public TracingStopChunkOptions(TracingStopChunkOptions clone)
47        {
48            if (clone == null)
49            {
50                return;
51            }
52
53            Path = clone.Path;
54        }
55
56        /// <summary>
57        /// <para>
58        /// Export trace collected since the last <see cref="ITracing.StartChunkAsync"/> call
59        /// into the file with the given path.
60        /// </para>
61        /// </summary>
62        [JsonPropertyName("path")]
63        public string? Path { get; set; }
64    }
65}
66
67#nullable disable
68
Full Screen

ITracing.cs

Source: ITracing.cs Github

copy
1/*
2 * MIT License
3 *
4 * Copyright (c) Microsoft Corporation.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24
25using System;
26using System.Collections.Generic;
27using System.ComponentModel.DataAnnotations;
28using System.Drawing;
29using System.Globalization;
30using System.IO;
31using System.Runtime.Serialization;
32using System.Text.Json;
33using System.Text.Json.Serialization;
34using System.Text.RegularExpressions;
35using System.Threading;
36using System.Threading.Tasks;
37
38#nullable enable
39
40namespace Microsoft.Playwright
41{
42    /// <summary>
43    /// <para>
44    /// API for collecting and saving Playwright traces. Playwright traces can be opened
45    /// in <a href="https://playwright.dev/dotnet/docs/trace-viewer">Trace Viewer</a> after
46    /// Playwright script runs.
47    /// </para>
48    /// <para>
49    /// Start recording a trace before performing actions. At the end, stop tracing and
50    /// save it to a file.
51    /// </para>
52    /// <code>
53    /// await using var browser = playwright.Chromium.LaunchAsync();<br/>
54    /// await using var context = await browser.NewContextAsync();<br/>
55    /// await context.Tracing.StartAsync(new TracingStartOptions<br/>
56    /// {<br/>
57    ///   Screenshots: true,<br/>
58    ///   Snapshots: true<br/>
59    /// });<br/>
60    /// var page = context.NewPageAsync();<br/>
61    /// await page.GotoAsync("https://playwright.dev");<br/>
62    /// await context.Tracing.StopAsync(new TracingStopOptions<br/>
63    /// {<br/>
64    ///   Path: "trace.zip"<br/>
65    /// });
66    /// </code>
67    /// </summary>
68    public partial interface ITracing
69    {
70        /// <summary>
71        /// <para>Start tracing.</para>
72        /// <code>
73        /// await using var browser = playwright.Chromium.LaunchAsync();<br/>
74        /// await using var context = await browser.NewContextAsync();<br/>
75        /// await context.Tracing.StartAsync(new TracingStartOptions<br/>
76        /// {<br/>
77        ///   Screenshots: true,<br/>
78        ///   Snapshots: true<br/>
79        /// });<br/>
80        /// var page = context.NewPageAsync();<br/>
81        /// await page.GotoAsync("https://playwright.dev");<br/>
82        /// await context.Tracing.StopAsync(new TracingStopOptions<br/>
83        /// {<br/>
84        ///   Path: "trace.zip"<br/>
85        /// });
86        /// </code>
87        /// </summary>
88        /// <param name="options">Call options</param>
89        Task StartAsync(TracingStartOptions? options = default);
90
91        /// <summary>
92        /// <para>
93        /// Start a new trace chunk. If you'd like to record multiple traces on the same <see
94        /// cref="IBrowserContext"/>, use <see cref="ITracing.StartAsync"/> once, and then create
95        /// multiple trace chunks with <see cref="ITracing.StartChunkAsync"/> and <see cref="ITracing.StopChunkAsync"/>.
96        /// </para>
97        /// <code>
98        /// await using var browser = playwright.Chromium.LaunchAsync();<br/>
99        /// await using var context = await browser.NewContextAsync();<br/>
100        /// await context.Tracing.StartAsync(new TracingStartOptions<br/>
101        /// {<br/>
102        ///   Screenshots: true,<br/>
103        ///   Snapshots: true<br/>
104        /// });<br/>
105        /// var page = context.NewPageAsync();<br/>
106        /// await page.GotoAsync("https://playwright.dev");<br/>
107        /// <br/>
108        /// await context.Tracing.StartChunkAsync();<br/>
109        /// await page.ClickAsync("text=Get Started");<br/>
110        /// // Everything between StartChunkAsync and StopChunkAsync will be recorded in the trace.<br/>
111        /// await context.Tracing.StopChunkAsync(new TracingStopChunkOptions<br/>
112        /// {<br/>
113        ///   Path: "trace1.zip"<br/>
114        /// });<br/>
115        /// <br/>
116        /// await context.Tracing.StartChunkAsync();<br/>
117        /// await page.GotoAsync("http://example.com");<br/>
118        /// // Save a second trace file with different actions.<br/>
119        /// await context.Tracing.StopChunkAsync(new TracingStopChunkOptions<br/>
120        /// {<br/>
121        ///   Path: "trace2.zip"<br/>
122        /// });
123        /// </code>
124        /// </summary>
125        /// <param name="options">Call options</param>
126        Task StartChunkAsync(TracingStartChunkOptions? options = default);
127
128        /// <summary><para>Stop tracing.</para></summary>
129        /// <param name="options">Call options</param>
130        Task StopAsync(TracingStopOptions? options = default);
131
132        /// <summary>
133        /// <para>
134        /// Stop the trace chunk. See <see cref="ITracing.StartChunkAsync"/> for more details
135        /// about multiple trace chunks.
136        /// </para>
137        /// </summary>
138        /// <param name="options">Call options</param>
139        Task StopChunkAsync(TracingStopChunkOptions? options = default);
140    }
141}
142
143#nullable disable
144
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Most used method in TracingStopChunkOptions

Trigger TracingStopChunkOptions code on LambdaTest Cloud Grid

Execute automation tests with TracingStopChunkOptions on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)