Fetch WebDrive headless setting from config
This commit is contained in:
parent
7571512e0d
commit
b8083b2f38
|
|
@ -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,13 +34,10 @@ public class PlaywrightInstance : IDisposable
|
|||
|
||||
public async Task<IBrowserContext> GetContext(string ctxId)
|
||||
{
|
||||
var headless = true;
|
||||
#if DEBUG
|
||||
headless = false;
|
||||
#endif
|
||||
var _webDriver = _services.GetRequiredService<WebBrowsingSettings>();
|
||||
if (!_contexts.ContainsKey(ctxId))
|
||||
{
|
||||
await InitContext(ctxId, new BrowserActionArgs() { Headless = headless });
|
||||
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)
|
||||
|
|
@ -29,13 +34,9 @@ public class OpenBrowserFn : IFunctionCallback
|
|||
ContextId = convService.ConversationId,
|
||||
MessageId = message.MessageId
|
||||
};
|
||||
var headless = true;
|
||||
#if DEBUG
|
||||
headless = false;
|
||||
#endif
|
||||
var result = await _browser.LaunchBrowser(msgInfo, new BrowserActionArgs
|
||||
{
|
||||
Headless = headless
|
||||
Headless = _webBrowsingSettings.Headless
|
||||
});
|
||||
result = await _browser.GoToPage(msgInfo, new PageActionArgs
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue