Remove openIfNotExist from LaunchBrowser
This commit is contained in:
parent
9213c7fa5b
commit
e9ae471a65
|
|
@ -4,7 +4,7 @@ namespace BotSharp.Abstraction.Browsing;
|
|||
|
||||
public interface IWebBrowser
|
||||
{
|
||||
Task<BrowserActionResult> LaunchBrowser(string contextId, string? url, bool openIfNotExist = true);
|
||||
Task<BrowserActionResult> LaunchBrowser(string contextId, string? url);
|
||||
Task<BrowserActionResult> ScreenshotAsync(string contextId, string path);
|
||||
Task<BrowserActionResult> ScrollPageAsync(BrowserActionParams actionParams);
|
||||
|
||||
|
|
|
|||
|
|
@ -5,13 +5,29 @@ public partial class PlaywrightWebDriver
|
|||
public async Task<BrowserActionResult> GoToPage(string contextId, string url, bool openNewTab = false)
|
||||
{
|
||||
var result = new BrowserActionResult();
|
||||
var context = await _instance.InitInstance(contextId);
|
||||
try
|
||||
{
|
||||
// Check if the page is already open
|
||||
foreach (var p in context.Pages)
|
||||
{
|
||||
if (p.Url == url)
|
||||
{
|
||||
result.Body = await p.ContentAsync();
|
||||
result.IsSuccess = true;
|
||||
await p.BringToFrontAsync();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
var page = openNewTab ? await _instance.NewPage(contextId) :
|
||||
_instance.GetPage(contextId);
|
||||
var response = await page.GotoAsync(url);
|
||||
await page.WaitForLoadStateAsync(LoadState.DOMContentLoaded);
|
||||
await page.WaitForLoadStateAsync(LoadState.NetworkIdle);
|
||||
await page.WaitForLoadStateAsync(LoadState.NetworkIdle, new PageWaitForLoadStateOptions
|
||||
{
|
||||
Timeout = 1000 * 60 * 5
|
||||
});
|
||||
|
||||
if (response.Status == 200)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ namespace BotSharp.Plugin.WebDriver.Drivers.PlaywrightDriver;
|
|||
|
||||
public partial class PlaywrightWebDriver
|
||||
{
|
||||
public async Task<BrowserActionResult> LaunchBrowser(string contextId, string? url, bool openIfNotExist = true)
|
||||
public async Task<BrowserActionResult> LaunchBrowser(string contextId, string? url)
|
||||
{
|
||||
var result = new BrowserActionResult()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -87,8 +87,8 @@ public partial class PlaywrightWebDriver
|
|||
await locator.EvaluateAsync("element => element.style.opacity = '1.0'");
|
||||
}*/
|
||||
|
||||
var text = await locator.InnerTextAsync();
|
||||
result.Body = text;
|
||||
var html = await locator.InnerHTMLAsync();
|
||||
result.Body = html;
|
||||
result.IsSuccess = true;
|
||||
}
|
||||
else if (count > 1)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ namespace BotSharp.Plugin.WebDriver.Drivers.SeleniumDriver;
|
|||
|
||||
public partial class SeleniumWebDriver
|
||||
{
|
||||
public async Task<BrowserActionResult> LaunchBrowser(string contextId, string? url, bool openIfNotExist = true)
|
||||
public async Task<BrowserActionResult> LaunchBrowser(string contextId, string? url)
|
||||
{
|
||||
var result = new BrowserActionResult()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue