From 3f7242a2645267ec41c8fe1d37fb8106af7c97a7 Mon Sep 17 00:00:00 2001 From: Haiping Chen Date: Wed, 15 Jan 2025 06:39:26 +0000 Subject: [PATCH] =?UTF-8?q?=E7=94=A8post=E5=8F=96=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Browsing/Models/HttpRequestParams.cs | 2 ++ .../Drivers/PlaywrightDriver/PlaywrightInstance.cs | 13 +++++++++++++ .../PlaywrightWebDriver.GoToPage.cs | 5 +++++ 3 files changed, 20 insertions(+) diff --git a/src/Infrastructure/BotSharp.Abstraction/Browsing/Models/HttpRequestParams.cs b/src/Infrastructure/BotSharp.Abstraction/Browsing/Models/HttpRequestParams.cs index e6d24a8e..743a12b5 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Browsing/Models/HttpRequestParams.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Browsing/Models/HttpRequestParams.cs @@ -1,7 +1,9 @@ +using System.Diagnostics; using System.Net.Http; namespace BotSharp.Abstraction.Browsing.Models; +[DebuggerStepThrough] public class HttpRequestParams { [JsonPropertyName("url")] diff --git a/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/PlaywrightDriver/PlaywrightInstance.cs b/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/PlaywrightDriver/PlaywrightInstance.cs index 95b88eee..cb24bfec 100644 --- a/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/PlaywrightDriver/PlaywrightInstance.cs +++ b/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/PlaywrightDriver/PlaywrightInstance.cs @@ -1,3 +1,4 @@ +using Azure; using System.IO; namespace BotSharp.Plugin.WebDriver.Drivers.PlaywrightDriver; @@ -123,6 +124,11 @@ public class PlaywrightInstance : IDisposable return page; } + page.Request += async (sender, e) => + { + await HandleFetchRequest(e, message, args); + }; + page.Response += async (sender, e) => { await HandleFetchResponse(e, message, args); @@ -131,6 +137,13 @@ public class PlaywrightInstance : IDisposable return page; } + public async Task HandleFetchRequest(IRequest request, MessageInfo message, PageActionArgs args) + { + if (request.ResourceType == "fetch" || request.ResourceType == "xhr") + { + } + } + public async Task HandleFetchResponse(IResponse response, MessageInfo message, PageActionArgs args) { if (response.Status != 204 && diff --git a/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/PlaywrightDriver/PlaywrightWebDriver.GoToPage.cs b/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/PlaywrightDriver/PlaywrightWebDriver.GoToPage.cs index 7f0501cf..371a8c06 100644 --- a/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/PlaywrightDriver/PlaywrightWebDriver.GoToPage.cs +++ b/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/PlaywrightDriver/PlaywrightWebDriver.GoToPage.cs @@ -21,6 +21,11 @@ public partial class PlaywrightWebDriver if (args.EnableResponseCallback) { + page.Request += async (sender, e) => + { + await _instance.HandleFetchRequest(e, message, args); + }; + page.Response += async (sender, e) => { await _instance.HandleFetchResponse(e, message, args);