Skip to content

Commit bf22260

Browse files
committed
商品导入
1 parent e8d1824 commit bf22260

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/Plugins/BotSharp.Plugin.WebDriver/Drivers/PlaywrightDriver/PlaywrightWebDriver.LocateElement.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ public async Task<BrowserActionResult> LocateElement(MessageInfo message, Elemen
1414
{
1515
var result = new BrowserActionResult();
1616
var page = _instance.GetPage(message.ContextId);
17+
if (page == null)
18+
{
19+
return new BrowserActionResult
20+
{
21+
IsSuccess = false
22+
};
23+
}
1724
ILocator locator = page.Locator("body");
1825
int count = 0;
1926

src/Plugins/BotSharp.Plugin.WebDriver/WebPageHelper.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
11
using HtmlAgilityPack;
2-
using System.Net.Http;
32

43
namespace BotSharp.Plugin.WebDriver;
54

65
public static class WebPageHelper
76
{
7+
public static HtmlNode GetElement(string html, string selector)
8+
{
9+
var htmlDoc = new HtmlDocument();
10+
htmlDoc.LoadHtml(html);
11+
12+
return htmlDoc.DocumentNode.SelectSingleNode(selector);
13+
}
14+
15+
public static HtmlNodeCollection GetElements(string html, string selector)
16+
{
17+
var htmlDoc = new HtmlDocument();
18+
htmlDoc.LoadHtml(html);
19+
20+
return htmlDoc.DocumentNode.SelectNodes(selector);
21+
}
22+
823
public static string RemoveElements(string html, string selector)
924
{
1025
var htmlDoc = new HtmlDocument();

0 commit comments

Comments
 (0)