add web driver get attribute value
This commit is contained in:
parent
37716e3bde
commit
b2ac5707ae
|
|
@ -24,4 +24,5 @@ public interface IWebBrowser
|
|||
Task<T> EvaluateScript<T>(string conversationId, string script);
|
||||
Task CloseBrowser(string conversationId);
|
||||
Task<BrowserActionResult> SendHttpRequest(BrowserActionParams actionParams);
|
||||
Task<string> GetAttributeValue(MessageInfo message, ElementLocatingArgs location, BrowserActionResult result);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,4 +26,19 @@ public class VideoSnippet
|
|||
public string Title { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string ChannelTitle { get; set; }
|
||||
public VideoThumbnails Thumbnails { get; set; }
|
||||
}
|
||||
|
||||
public class VideoThumbnails
|
||||
{
|
||||
public ThumbnailData Default { get; set; }
|
||||
public ThumbnailData Medium { get; set; }
|
||||
public ThumbnailData High { get; set; }
|
||||
}
|
||||
|
||||
public class ThumbnailData
|
||||
{
|
||||
public string Url { get; set; }
|
||||
public decimal Width { get; set; }
|
||||
public decimal Height { get; set; }
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
namespace BotSharp.Plugin.WebDriver.Drivers.PlaywrightDriver;
|
||||
|
||||
public partial class PlaywrightWebDriver
|
||||
{
|
||||
public async Task<string> GetAttributeValue(MessageInfo message, ElementLocatingArgs location, BrowserActionResult result)
|
||||
{
|
||||
var page = _instance.GetPage(message.ConversationId);
|
||||
ILocator locator = page.Locator(result.Selector);
|
||||
var value = string.Empty;
|
||||
|
||||
if (!string.IsNullOrEmpty(location?.AttributeName))
|
||||
{
|
||||
value = await locator.GetAttributeAsync(location.AttributeName);
|
||||
}
|
||||
|
||||
return value ?? string.Empty;
|
||||
}
|
||||
}
|
||||
|
|
@ -45,7 +45,7 @@ public partial class PlaywrightWebDriver
|
|||
}
|
||||
}
|
||||
|
||||
if (location.Index > 0)
|
||||
if (location.Index >= 0)
|
||||
{
|
||||
locator = locator.Nth(location.Index);
|
||||
count = await locator.CountAsync();
|
||||
|
|
|
|||
|
|
@ -224,7 +224,7 @@
|
|||
"Youtube": {
|
||||
"Endpoint": "https://www.googleapis.com/youtube/v3/search",
|
||||
"RegionCode": "US",
|
||||
"Part": "id"
|
||||
"Part": "id,snippet"
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue