Add customization for web driver.
This commit is contained in:
parent
1c034c88aa
commit
4cde28f095
|
|
@ -16,7 +16,10 @@ public class PageActionArgs
|
|||
/// <summary>
|
||||
/// This value has to be set to true if you want to get the page XHR/ Fetch responses
|
||||
/// </summary>
|
||||
public bool OpenNewTab { get; set; } = false;
|
||||
[JsonPropertyName("open_new_tab")]
|
||||
public bool OpenNewTab { get; set; } = true;
|
||||
[JsonPropertyName("open_blank_page")]
|
||||
public bool OpenBlankPage { get; set; } = true;
|
||||
|
||||
public bool EnableResponseCallback { get; set; } = false;
|
||||
|
||||
|
|
@ -47,4 +50,6 @@ public class PageActionArgs
|
|||
public int WaitTime { get; set; }
|
||||
|
||||
public bool ReadInnerHTMLAsBody { get; set; } = false;
|
||||
[JsonPropertyName("keep_browser_open")]
|
||||
public bool KeepBrowserOpen { get; set; } = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,14 @@ public partial class PlaywrightWebDriver
|
|||
|
||||
if (page != null)
|
||||
{
|
||||
if (page.Url != "about:blank")
|
||||
if (!args.OpenBlankPage)
|
||||
{
|
||||
if (!_instance.Pages[message.ContextId].Contains(page))
|
||||
{
|
||||
_instance.Pages[message.ContextId].Add(page);
|
||||
}
|
||||
}
|
||||
if (args.OpenBlankPage && page.Url != "about:blank")
|
||||
{
|
||||
await page.EvaluateAsync(@"() => {
|
||||
window.open('', '_blank');
|
||||
|
|
@ -48,7 +55,6 @@ public partial class PlaywrightWebDriver
|
|||
|
||||
// Active current tab
|
||||
await page.BringToFrontAsync();
|
||||
|
||||
var response = await page.GotoAsync(args.Url, new PageGotoOptions
|
||||
{
|
||||
Timeout = args.Timeout > 0 ? args.Timeout : 30000
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ public class UtilWebGoToPageFn : IFunctionCallback
|
|||
args.Timeout = _webDriver.DefaultTimeout;
|
||||
args.WaitForNetworkIdle = false;
|
||||
args.WaitTime = _webDriver.DefaultWaitTime;
|
||||
args.OpenNewTab = true;
|
||||
|
||||
var conv = _services.GetRequiredService<IConversationService>();
|
||||
|
||||
|
|
@ -38,7 +37,10 @@ public class UtilWebGoToPageFn : IFunctionCallback
|
|||
MessageId = message.MessageId,
|
||||
ContextId = message.CurrentAgentId,
|
||||
};
|
||||
await browser.CloseCurrentPage(msg);
|
||||
if (!args.KeepBrowserOpen)
|
||||
{
|
||||
await browser.CloseCurrentPage(msg);
|
||||
}
|
||||
var result = await browser.GoToPage(msg, args);
|
||||
if (!result.IsSuccess)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,6 +7,14 @@
|
|||
"url": {
|
||||
"type": "string",
|
||||
"description": "Web URL"
|
||||
},
|
||||
"open_new_tab": {
|
||||
"type": "boolean",
|
||||
"description": "Open new tab"
|
||||
},
|
||||
"open_blank_page": {
|
||||
"type": "boolean",
|
||||
"description": "Open blank page"
|
||||
}
|
||||
},
|
||||
"required": [ "url" ]
|
||||
|
|
|
|||
Loading…
Reference in a new issue