IgnoreIfNotFound
This commit is contained in:
parent
2e5abe50ea
commit
f6651b5d33
|
|
@ -26,6 +26,7 @@ public class ElementLocatingArgs
|
|||
public bool Parent { get; set; }
|
||||
|
||||
public bool FailIfMultiple { get; set; }
|
||||
public bool IgnoreIfNotFound { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Draw outline around the element
|
||||
|
|
|
|||
|
|
@ -12,5 +12,5 @@ public class MessageInfo : ICacheKey
|
|||
public string StepId { get; set; } = Guid.NewGuid().ToString();
|
||||
|
||||
public string GetCacheKey()
|
||||
=> $"{nameof(MessageInfo)}-{AgentId}-{UserId}-{ContextId}-{MessageId}-{TaskId}";
|
||||
=> $"{nameof(MessageInfo)}-{ContextId}";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -164,22 +164,22 @@ public class PlaywrightInstance : IDisposable
|
|||
Serilog.Log.Warning($"Response status: {e.Status} {e.StatusText}, OK: {e.Ok}");
|
||||
}
|
||||
|
||||
var result = new WebPageResponseData
|
||||
{
|
||||
Url = e.Url.ToLower(),
|
||||
PostData = e.Request?.PostData ?? string.Empty,
|
||||
ResponseData = JsonSerializer.Serialize(json),
|
||||
ResponseInMemory = responseInMemory
|
||||
};
|
||||
|
||||
if (responseContainer != null && responseInMemory)
|
||||
{
|
||||
responseContainer.Add(result);
|
||||
}
|
||||
|
||||
var webPageResponseHooks = _services.GetServices<IWebPageResponseHook>();
|
||||
foreach (var hook in webPageResponseHooks)
|
||||
{
|
||||
var result = new WebPageResponseData
|
||||
{
|
||||
Url = e.Url.ToLower(),
|
||||
PostData = e.Request?.PostData ?? string.Empty,
|
||||
ResponseData = JsonSerializer.Serialize(json),
|
||||
ResponseInMemory = responseInMemory
|
||||
};
|
||||
|
||||
if (responseContainer != null && responseInMemory)
|
||||
{
|
||||
responseContainer.Add(result);
|
||||
}
|
||||
|
||||
hook.OnDataFetched(message, result);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,8 +68,17 @@ public partial class PlaywrightWebDriver
|
|||
|
||||
if (count == 0)
|
||||
{
|
||||
result.Message = $"Can't locate element by keyword {location.Text}";
|
||||
_logger.LogError(result.Message);
|
||||
if (location.IgnoreIfNotFound)
|
||||
{
|
||||
result.Message = $"Can't locate element by keyword {location.Text} and Ignored";
|
||||
_logger.LogWarning(result.Message);
|
||||
}
|
||||
else
|
||||
{
|
||||
result.Message = $"Can't locate element by keyword {location.Text}";
|
||||
_logger.LogError(result.Message);
|
||||
}
|
||||
|
||||
}
|
||||
else if (count == 1)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue