add read content to locate element utility
This commit is contained in:
parent
8ec7ecdf55
commit
fc1af807c3
|
|
@ -36,4 +36,6 @@ public class ElementLocatingArgs
|
|||
/// </summary>
|
||||
public bool Highlight { get; set; }
|
||||
public string HighlightColor { get; set; } = "red";
|
||||
[JsonPropertyName("is_read_content")]
|
||||
public bool IsReadContent { get;set; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,11 @@ public class UtilWebLocateElementFn : IFunctionCallback
|
|||
};
|
||||
var result = await browser.LocateElement(msg, locatorArgs);
|
||||
|
||||
message.Content = $"Locating element {(result.IsSuccess ? "success" : "failed")}";
|
||||
message.Content = $"Locating element {(result.IsSuccess ? "success" : "failed")}. ";
|
||||
if (locatorArgs.IsReadContent && result.IsSuccess && !string.IsNullOrWhiteSpace(result.Body))
|
||||
{
|
||||
message.Content += $"Content is: \n{result.Body}";
|
||||
}
|
||||
|
||||
var path = webDriverService.GetScreenshotFilePath(message.MessageId);
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,10 @@
|
|||
"selector": {
|
||||
"type": "string",
|
||||
"description": "element selector in XPath, use syntax of Playwright in .NET"
|
||||
},
|
||||
"is_read_content": {
|
||||
"type": "boolean",
|
||||
"description": "read the content"
|
||||
}
|
||||
},
|
||||
"required": [ "selector" ]
|
||||
|
|
|
|||
Loading…
Reference in a new issue