Skip to content

move data to WebStarter #888

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,18 @@
Task DoAction(MessageInfo message, ElementActionArgs action, BrowserActionResult result);
Task PressKey(MessageInfo message, string key);

Task<BrowserActionResult> InputUserText(BrowserActionParams actionParams);

Check warning on line 17 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'

Check warning on line 17 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'

Check warning on line 17 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'

Check warning on line 17 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'

Check warning on line 17 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'

Check warning on line 17 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'
Task<BrowserActionResult> InputUserPassword(BrowserActionParams actionParams);

Check warning on line 18 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'

Check warning on line 18 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'

Check warning on line 18 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'

Check warning on line 18 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'

Check warning on line 18 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'

Check warning on line 18 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'
Task<BrowserActionResult> ClickButton(BrowserActionParams actionParams);

Check warning on line 19 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'

Check warning on line 19 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'

Check warning on line 19 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'

Check warning on line 19 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'

Check warning on line 19 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'

Check warning on line 19 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'
Task<BrowserActionResult> ClickElement(BrowserActionParams actionParams);

Check warning on line 20 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'

Check warning on line 20 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'

Check warning on line 20 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'

Check warning on line 20 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'

Check warning on line 20 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'

Check warning on line 20 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'
Task<BrowserActionResult> ChangeListValue(BrowserActionParams actionParams);

Check warning on line 21 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'

Check warning on line 21 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'

Check warning on line 21 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'

Check warning on line 21 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'

Check warning on line 21 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'

Check warning on line 21 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'
Task<BrowserActionResult> CheckRadioButton(BrowserActionParams actionParams);

Check warning on line 22 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'

Check warning on line 22 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'

Check warning on line 22 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'

Check warning on line 22 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'

Check warning on line 22 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'

Check warning on line 22 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'
Task<BrowserActionResult> ChangeCheckbox(BrowserActionParams actionParams);

Check warning on line 23 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'

Check warning on line 23 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'

Check warning on line 23 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'

Check warning on line 23 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'

Check warning on line 23 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'

Check warning on line 23 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'
Task<BrowserActionResult> GoToPage(MessageInfo message, PageActionArgs args);
Task<string> ExtractData(BrowserActionParams actionParams);

Check warning on line 25 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'

Check warning on line 25 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'

Check warning on line 25 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'

Check warning on line 25 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'

Check warning on line 25 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'

Check warning on line 25 in src/Infrastructure/BotSharp.Abstraction/Browsing/IWebBrowser.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

'BrowserActionParams' is obsolete: 'This class is deprecated, use BrowserActionArgs instead.'
Task<T> EvaluateScript<T>(string contextId, string script);
Task CloseBrowser(string contextId);
Task<bool> IsBrowserClosed(string contextId);
Task<BrowserActionResult> CloseCurrentPage(MessageInfo message);
Task<BrowserActionResult> SendHttpRequest(MessageInfo message, HttpRequestParams actionParams);
Task<BrowserActionResult> GetAttributeValue(MessageInfo message, ElementLocatingArgs location);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public class ConversationStateService : IConversationStateService, IDisposable
private readonly ILogger _logger;
private readonly IServiceProvider _services;
private readonly IBotSharpRepository _db;
private readonly IConversationSideCar _sidecar;
private string _conversationId;
/// <summary>
/// States in the current round of conversation
Expand All @@ -41,12 +40,10 @@ public class ConversationStateService : IConversationStateService, IDisposable
public ConversationStateService(
IServiceProvider services,
IBotSharpRepository db,
IConversationSideCar sidecar,
ILogger<ConversationStateService> logger)
{
_services = services;
_db = db;
_sidecar = sidecar;
_logger = logger;
_curStates = new ConversationState();
_historyStates = new ConversationState();
Expand Down Expand Up @@ -142,8 +139,9 @@ public Dictionary<string, string> Load(string conversationId, bool isReadOnly =
_conversationId = !isReadOnly ? conversationId : null;
Reset();

var sidecar = _services.GetService<IConversationSideCar>();
var endNodes = new Dictionary<string, string>();
if (_sidecar?.IsEnabled() == true)
if (sidecar?.IsEnabled() == true)
{
return endNodes;
}
Expand Down Expand Up @@ -219,7 +217,8 @@ public Dictionary<string, string> Load(string conversationId, bool isReadOnly =

public void Save()
{
if (_conversationId == null || _sidecar?.IsEnabled() == true)
var sidecar = _services.GetService<IConversationSideCar>();
if (_conversationId == null || sidecar?.IsEnabled() == true)
{
Reset();
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>$(TargetFramework)</TargetFramework>
Expand All @@ -16,31 +16,15 @@
</ItemGroup>

<ItemGroup>
<None Remove="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\agent.json" />
<None Remove="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\functions\change_checkbox.json" />
<None Remove="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\functions\change_list_value.json" />
<None Remove="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\functions\check_radio_button.json" />
<None Remove="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\functions\click_button.json" />
<None Remove="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\functions\click_element.json" />
<None Remove="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\functions\close_browser.json" />
<None Remove="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\functions\extract_data_from_page.json" />
<None Remove="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\functions\go_to_page.json" />
<None Remove="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\functions\input_user_password.json" />
<None Remove="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\functions\input_user_text.json" />
<None Remove="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\functions\open_browser.json" />
<None Remove="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\functions\scroll_page.json" />
<None Remove="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\functions\send_http_request.json" />
<None Remove="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\functions\take_screenshot.json" />
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\util-web-action_on_element.fn.liquid" />
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\util-web-go_to_page.fn.liquid" />
<None Remove="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\instructions\instruction.liquid" />
<None Remove="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\templates\extract_data.liquid" />
<None Remove="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\templates\html_parser.liquid" />
<None Remove="README.md" />
</ItemGroup>

<ItemGroup>
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\functions\util-web-locate_element.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\functions\util-web-action_on_element.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand All @@ -50,6 +34,9 @@
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\functions\util-web-go_to_page.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\functions\util-web-locate_element.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\util-web-action_on_element.fn.liquid">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand All @@ -59,15 +46,6 @@
<Content Include="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\agent.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\instructions\instruction.liquid">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\templates\extract_data.liquid">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\templates\html_parser.liquid">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\functions\change_checkbox.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand Down Expand Up @@ -110,6 +88,15 @@
<Content Include="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\functions\take_screenshot.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\instructions\instruction.liquid">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\templates\extract_data.liquid">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\templates\html_parser.liquid">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ public async Task<IBrowserContext> InitContext(string ctxId, BrowserActionArgs a
}
else
{
string userDataDir = args.UserDataDir ?? $"{Path.GetTempPath()}\\playwright\\{ctxId}";
string localAppDataFolder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
string userDataDir = args.UserDataDir ?? $"{localAppDataFolder}\\playwright\\{ctxId}";
_contexts[ctxId] = await _playwright.Chromium.LaunchPersistentContextAsync(userDataDir, new BrowserTypeLaunchPersistentContextOptions
{
Headless = args.Headless,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ public async Task<BrowserActionResult> GoToPage(MessageInfo message, PageActionA

if (page != null)
{
await page.EvaluateAsync(@"() => {
window.open('', '_blank');
}");
if (page.Url != "about:blank")
{
await page.EvaluateAsync(@"() => {
window.open('', '_blank');
}");
}

if (args.EnableResponseCallback)
{
Expand All @@ -36,13 +39,6 @@ await page.EvaluateAsync(@"() => {
else
{
page = await _instance.NewPage(message, args);

Serilog.Log.Information($"goto page: {args.Url}");

if (args.OpenNewTab && page != null && page.Url == "about:blank")
{
page = await _instance.NewPage(message, args);
}
}

if (page == null)
Expand Down Expand Up @@ -95,6 +91,7 @@ await page.EvaluateAsync(@"() => {
}

result.ResponseStatusCode = response.Status;
result.UrlAfterAction = page.Url;
if (response.Status == 200)
{
result.IsSuccess = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,9 @@ public async Task PressKey(MessageInfo message, string key)
await page.Keyboard.PressAsync(key);
}
}

public async Task<bool> IsBrowserClosed(string contextId)
{
return !_instance.Contexts.ContainsKey(contextId);
}
}
Loading