1+ // <copyright file="RemoteNetwork.cs" company="WebDriver Committers">
2+ // Licensed to the Software Freedom Conservancy (SFC) under one
3+ // or more contributor license agreements. See the NOTICE file
4+ // distributed with this work for additional information
5+ // regarding copyright ownership. The SFC licenses this file
6+ // to you under the Apache License, Version 2.0 (the "License");
7+ // you may not use this file except in compliance with the License.
8+ // You may obtain a copy of the License at
9+ //
10+ // http://www.apache.org/licenses/LICENSE-2.0
11+ //
12+ // Unless required by applicable law or agreed to in writing, software
13+ // distributed under the License is distributed on an "AS IS" BASIS,
14+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+ // See the License for the specific language governing permissions and
16+ // limitations under the License.
17+ // </copyright>
18+
119using System ;
220using System . Collections . Generic ;
3- using System . Linq ;
4- using System . Text ;
521using System . Threading . Tasks ;
622using OpenQA . Selenium . DevTools ;
723
824namespace OpenQA . Selenium . Remote
925{
26+ /// <summary>
27+ /// Provides methods for monitoring, intercepting, and modifying network requests and responses.
28+ /// </summary>
1029 public class RemoteNetwork : INetwork
1130 {
1231 private Lazy < DevToolsSession > session ;
1332 private List < NetworkRequestHandler > requestHandlers = new List < NetworkRequestHandler > ( ) ;
1433 private List < NetworkAuthenticationHandler > authenticationHandlers = new List < NetworkAuthenticationHandler > ( ) ;
1534
35+ /// <summary>
36+ /// Initializes a new instance of the <see cref="RemoteNetwork"/> class.
37+ /// </summary>
38+ /// <param name="driver">The <see cref="IWebDriver"/> instance on which the network should be monitored.</param>
1639 public RemoteNetwork ( IWebDriver driver )
1740 {
1841 // Use of Lazy<T> means this exception won't be thrown until the user first
@@ -30,9 +53,20 @@ public RemoteNetwork(IWebDriver driver)
3053 } ) ;
3154 }
3255
33- public event EventHandler < NetworkResponseRecievedEventArgs > NetworkResponseReceived ;
56+ /// <summary>
57+ /// Occurs when a browser sends a network request.
58+ /// </summary>
3459 public event EventHandler < NetworkRequestSentEventArgs > NetworkRequestSent ;
3560
61+ /// <summary>
62+ /// Occurs when a browser receives a network response.
63+ /// </summary>
64+ public event EventHandler < NetworkResponseRecievedEventArgs > NetworkResponseReceived ;
65+
66+ /// <summary>
67+ /// Asynchronously starts monitoring for network traffic.
68+ /// </summary>
69+ /// <returns>A task that represents the asynchronous operation.</returns>
3670 public async Task StartMonitoring ( )
3771 {
3872 this . session . Value . Domains . Network . RequestPaused += OnRequestPaused ;
@@ -43,6 +77,10 @@ public async Task StartMonitoring()
4377 await this . session . Value . Domains . Network . DisableNetworkCaching ( ) ;
4478 }
4579
80+ /// <summary>
81+ /// Asynchronously stops monitoring for network traffic.
82+ /// </summary>
83+ /// <returns>A task that represents the asynchronous operation.</returns>
4684 public async Task StopMonitoring ( )
4785 {
4886 this . session . Value . Domains . Network . ResponsePaused -= OnResponsePaused ;
@@ -51,6 +89,11 @@ public async Task StopMonitoring()
5189 await this . session . Value . Domains . Network . EnableNetworkCaching ( ) ;
5290 }
5391
92+ /// <summary>
93+ /// Adds a <see cref="NetworkRequestHandler"/> to examine incoming network requests,
94+ /// and optionally modify the request or provide a response.
95+ /// </summary>
96+ /// <param name="handler">The <see cref="NetworkRequestHandler"/> to add.</param>
5497 public void AddRequestHandler ( NetworkRequestHandler handler )
5598 {
5699 if ( handler == null )
@@ -71,11 +114,19 @@ public void AddRequestHandler(NetworkRequestHandler handler)
71114 this . requestHandlers . Add ( handler ) ;
72115 }
73116
117+ /// <summary>
118+ /// Clears all added <see cref="NetworkRequestHandler"/> instances.
119+ /// </summary>
74120 public void ClearRequestHandlers ( )
75121 {
76122 this . requestHandlers . Clear ( ) ;
77123 }
78124
125+ /// <summary>
126+ /// Adds a <see cref="NetworkAuthenticationHandler"/> to supply authentication
127+ /// credentials for network requests.
128+ /// </summary>
129+ /// <param name="handler">The <see cref="NetworkAuthenticationHandler"/> to add.</param>
79130 public void AddAuthenticationHandler ( NetworkAuthenticationHandler handler )
80131 {
81132 if ( handler == null )
@@ -102,6 +153,9 @@ public void AddAuthenticationHandler(NetworkAuthenticationHandler handler)
102153 this . authenticationHandlers . Add ( handler ) ;
103154 }
104155
156+ /// <summary>
157+ /// Clears all added <see cref="NetworkAuthenticationHandler"/> instances.
158+ /// </summary>
105159 public void ClearAuthenticationHandlers ( )
106160 {
107161 this . authenticationHandlers . Clear ( ) ;
0 commit comments