Replace special symbol for match rule.
This commit is contained in:
parent
77977f2aa1
commit
fbdd44b78d
|
|
@ -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()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue