Fix UserService.

This commit is contained in:
Haiping Chen 2024-05-23 07:05:36 -05:00
parent 3fd43964b7
commit f584c3190f
4 changed files with 28 additions and 4 deletions

View file

@ -8,4 +8,9 @@ public class BrowserActionResult
public string Selector { get; set; }
public string Body { get; set; }
public bool IsHighlighted { get; set; }
public override string ToString()
{
return $"{IsSuccess} - {Selector}";
}
}

View file

@ -5,6 +5,9 @@ public class ElementLocatingArgs
[JsonPropertyName("match_rule")]
public string MatchRule { get; set; } = string.Empty;
[JsonPropertyName("tag")]
public string? Tag { get; set; } = null!;
[JsonPropertyName("text")]
public string? Text { get; set; }
@ -20,6 +23,8 @@ public class ElementLocatingArgs
[JsonPropertyName("selector")]
public string? Selector { get; set; }
public bool Parent { get; set; }
public bool FailIfMultiple { get; set; }
/// <summary>

View file

@ -77,7 +77,7 @@ public class UserService : IUserService
record = db.GetUserByUserName(id);
}
User? user = null;
User? user = record;
var hooks = _services.GetServices<IAuthenticationHook>();
if (record == null || record.Source != "internal")
{

View file

@ -24,6 +24,12 @@ public partial class PlaywrightWebDriver
count = await locator.CountAsync();
}
if (location.Tag != null)
{
locator = page.Locator(location.Tag);
count = await locator.CountAsync();
}
// try attribute
if (!string.IsNullOrEmpty(location.AttributeName))
{
@ -66,12 +72,20 @@ public partial class PlaywrightWebDriver
}
else if (count == 1)
{
if (location.Parent)
{
locator = locator.Locator("..");
}
result.Selector = locator.ToString().Split('@').Last();
// Make sure the element is visible
await locator.EvaluateAsync("element => element.style.height = ''");
await locator.EvaluateAsync("element => element.style.width = ''");
await locator.EvaluateAsync("element => element.style.opacity = ''");
/*if (!await locator.IsVisibleAsync())
{
await locator.EvaluateAsync("element => element.style.height = '15px'");
await locator.EvaluateAsync("element => element.style.width = '15px'");
await locator.EvaluateAsync("element => element.style.opacity = '1.0'");
}*/
var text = await locator.InnerTextAsync();
result.Body = text;