Set UrlAfterAction

This commit is contained in:
Haiping Chen 2025-02-14 16:07:45 +00:00
parent 760a33052c
commit 9a6d22eeeb
2 changed files with 15 additions and 12 deletions

View file

@ -9,10 +9,16 @@
<GenerateDocumentationFile>$(GenerateDocumentationFile)</GenerateDocumentationFile>
<OutputPath>$(SolutionDir)packages</OutputPath>
</PropertyGroup>
<ItemGroup>
<Compile Remove="packages\**" />
<EmbeddedResource Remove="packages\**" />
<None Remove="packages\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Playwright" Version="1.49.0" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.71" />
<PackageReference Include="Microsoft.Playwright" Version="1.50.0" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.72" />
</ItemGroup>
<ItemGroup>

View file

@ -15,9 +15,12 @@ public partial class PlaywrightWebDriver
if (page != null)
{
await page.EvaluateAsync(@"() => {
window.open('', '_blank');
}");
if (page.Url != "about:blank")
{
await page.EvaluateAsync(@"() => {
window.open('', '_blank');
}");
}
if (args.EnableResponseCallback)
{
@ -36,13 +39,6 @@ public partial class PlaywrightWebDriver
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)
@ -95,6 +91,7 @@ public partial class PlaywrightWebDriver
}
result.ResponseStatusCode = response.Status;
result.UrlAfterAction = page.Url;
if (response.Status == 200)
{
result.IsSuccess = true;