Click on the body to give focus to the page

This commit is contained in:
Haiping Chen 2024-11-18 14:15:23 +00:00
parent f3b395ce01
commit ebd2688564
3 changed files with 8 additions and 2 deletions

View file

@ -20,8 +20,8 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Playwright" Version="1.45.1" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.62" />
<PackageReference Include="Microsoft.Playwright" Version="1.48.0" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.71" />
</ItemGroup>
<ItemGroup>

View file

@ -36,6 +36,9 @@ public partial class PlaywrightWebDriver
includeResponseUrls: args.IncludeResponseUrls);
}
// Active current tab
await page.BringToFrontAsync();
var response = await page.GotoAsync(args.Url, new PageGotoOptions
{
Timeout = args.Timeout > 0 ? args.Timeout : 30000

View file

@ -75,6 +75,9 @@ public partial class PlaywrightWebDriver : IWebBrowser
var page = _instance.GetPage(message.ContextId);
if (page != null)
{
// Click on the body to give focus to the page
await page.FocusAsync("input");
await page.Keyboard.PressAsync(key);
}
}