Merge pull request #929 from visagang/features/vguruparan
Update headless setting for Playwright
This commit is contained in:
commit
72a49a0a1a
|
|
@ -3,4 +3,5 @@ namespace BotSharp.Abstraction.Browsing.Settings;
|
|||
public class WebBrowsingSettings
|
||||
{
|
||||
public string Driver { get; set; } = "Playwright";
|
||||
public bool Headless { get; set; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using Azure;
|
||||
using BotSharp.Abstraction.Browsing.Settings;
|
||||
using System.IO;
|
||||
|
||||
namespace BotSharp.Plugin.WebDriver.Drivers.PlaywrightDriver;
|
||||
|
|
@ -33,9 +34,10 @@ public class PlaywrightInstance : IDisposable
|
|||
|
||||
public async Task<IBrowserContext> GetContext(string ctxId)
|
||||
{
|
||||
var _webDriver = _services.GetRequiredService<WebBrowsingSettings>();
|
||||
if (!_contexts.ContainsKey(ctxId))
|
||||
{
|
||||
await InitContext(ctxId, new BrowserActionArgs());
|
||||
await InitContext(ctxId, new BrowserActionArgs() { Headless = _webDriver.Headless });
|
||||
}
|
||||
return _contexts[ctxId];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
using BotSharp.Abstraction.Browsing.Settings;
|
||||
|
||||
namespace BotSharp.Plugin.WebDriver.Functions;
|
||||
|
||||
public class OpenBrowserFn : IFunctionCallback
|
||||
|
|
@ -6,12 +8,15 @@ public class OpenBrowserFn : IFunctionCallback
|
|||
|
||||
private readonly IServiceProvider _services;
|
||||
private readonly IWebBrowser _browser;
|
||||
private readonly WebBrowsingSettings _webBrowsingSettings;
|
||||
|
||||
public OpenBrowserFn(IServiceProvider services,
|
||||
IWebBrowser browser)
|
||||
IWebBrowser browser,
|
||||
WebBrowsingSettings webBrowsingSettings)
|
||||
{
|
||||
_services = services;
|
||||
_browser = browser;
|
||||
_webBrowsingSettings = webBrowsingSettings;
|
||||
}
|
||||
|
||||
public async Task<bool> Execute(RoleDialogModel message)
|
||||
|
|
@ -31,7 +36,7 @@ public class OpenBrowserFn : IFunctionCallback
|
|||
};
|
||||
var result = await _browser.LaunchBrowser(msgInfo, new BrowserActionArgs
|
||||
{
|
||||
Headless = false
|
||||
Headless = _webBrowsingSettings.Headless
|
||||
});
|
||||
result = await _browser.GoToPage(msgInfo, new PageActionArgs
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue