From fbdd44b78ded23e09466519f697a3c95aa0cb022 Mon Sep 17 00:00:00 2001 From: Haiping Chen Date: Fri, 28 Jun 2024 10:18:45 -0500 Subject: [PATCH] Replace special symbol for match rule. --- .../Browsing/Models/BrowserActionResult.cs | 1 - .../PlaywrightWebDriver.LocateElement.cs | 9 +++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Infrastructure/BotSharp.Abstraction/Browsing/Models/BrowserActionResult.cs b/src/Infrastructure/BotSharp.Abstraction/Browsing/Models/BrowserActionResult.cs index 63c592b7..b3576b90 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Browsing/Models/BrowserActionResult.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Browsing/Models/BrowserActionResult.cs @@ -8,7 +8,6 @@ public class BrowserActionResult public string Selector { get; set; } public string Body { get; set; } public bool IsHighlighted { get; set; } - public DateTime? ExecutedAt { get; set; } = DateTime.UtcNow; public override string ToString() { diff --git a/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/PlaywrightDriver/PlaywrightWebDriver.LocateElement.cs b/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/PlaywrightDriver/PlaywrightWebDriver.LocateElement.cs index 4bbd84ac..f62c230a 100644 --- a/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/PlaywrightDriver/PlaywrightWebDriver.LocateElement.cs +++ b/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/PlaywrightDriver/PlaywrightWebDriver.LocateElement.cs @@ -40,12 +40,13 @@ public partial class PlaywrightWebDriver // Retrieve the page raw html and infer the element path if (!string.IsNullOrEmpty(location.Text)) { + var text = location.Text.Replace("(", "\\(").Replace(")", "\\)"); var regexExpression = location.MatchRule.ToLower() switch { - "startwith" => $"^{location.Text}", - "endwith" => $"{location.Text}$", - "contains" => $"{location.Text}", - _ => $"^{location.Text}$" + "startwith" => $"^{text}", + "endwith" => $"{text}$", + "contains" => $"{text}", + _ => $"^{text}$" }; var regex = new Regex(regexExpression, RegexOptions.IgnoreCase); locator = locator.GetByText(regex);