File tree Expand file tree Collapse file tree 3 files changed +11
-3
lines changed
Infrastructure/BotSharp.Abstraction/Browsing/Settings
Plugins/BotSharp.Plugin.WebDriver Expand file tree Collapse file tree 3 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -3,4 +3,5 @@ namespace BotSharp.Abstraction.Browsing.Settings;
3
3
public class WebBrowsingSettings
4
4
{
5
5
public string Driver { get ; set ; } = "Playwright" ;
6
+ public bool Headless { get ; set ; }
6
7
}
Original file line number Diff line number Diff line change 1
1
using Azure ;
2
+ using BotSharp . Abstraction . Browsing . Settings ;
2
3
using System . IO ;
3
4
4
5
namespace BotSharp . Plugin . WebDriver . Drivers . PlaywrightDriver ;
@@ -33,9 +34,10 @@ public void SetServiceProvider(IServiceProvider services)
33
34
34
35
public async Task < IBrowserContext > GetContext ( string ctxId )
35
36
{
37
+ var _webDriver = _services . GetRequiredService < WebBrowsingSettings > ( ) ;
36
38
if ( ! _contexts . ContainsKey ( ctxId ) )
37
39
{
38
- await InitContext ( ctxId , new BrowserActionArgs ( ) ) ;
40
+ await InitContext ( ctxId , new BrowserActionArgs ( ) { Headless = _webDriver . Headless } ) ;
39
41
}
40
42
return _contexts [ ctxId ] ;
41
43
}
Original file line number Diff line number Diff line change
1
+ using BotSharp . Abstraction . Browsing . Settings ;
2
+
1
3
namespace BotSharp . Plugin . WebDriver . Functions ;
2
4
3
5
public class OpenBrowserFn : IFunctionCallback
@@ -6,12 +8,15 @@ public class OpenBrowserFn : IFunctionCallback
6
8
7
9
private readonly IServiceProvider _services ;
8
10
private readonly IWebBrowser _browser ;
11
+ private readonly WebBrowsingSettings _webBrowsingSettings ;
9
12
10
13
public OpenBrowserFn ( IServiceProvider services ,
11
- IWebBrowser browser )
14
+ IWebBrowser browser ,
15
+ WebBrowsingSettings webBrowsingSettings )
12
16
{
13
17
_services = services ;
14
18
_browser = browser ;
19
+ _webBrowsingSettings = webBrowsingSettings ;
15
20
}
16
21
17
22
public async Task < bool > Execute ( RoleDialogModel message )
@@ -31,7 +36,7 @@ public async Task<bool> Execute(RoleDialogModel message)
31
36
} ;
32
37
var result = await _browser . LaunchBrowser ( msgInfo , new BrowserActionArgs
33
38
{
34
- Headless = false
39
+ Headless = _webBrowsingSettings . Headless
35
40
} ) ;
36
41
result = await _browser . GoToPage ( msgInfo , new PageActionArgs
37
42
{
You can’t perform that action at this time.
0 commit comments