Fix flaky alert message lookup

This commit is contained in:
Dennis Reimann 2021-11-24 12:25:14 +01:00 committed by Andrew Camilleri
parent 3b3fac98ad
commit d555d2f3f6

View file

@ -2,6 +2,7 @@ using System;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
@ -98,7 +99,15 @@ namespace BTCPayServer.Tests
internal IWebElement FindAlertMessage(params StatusMessageModel.StatusSeverity[] severity)
{
var className = string.Join(", ", severity.Select(statusSeverity => $".alert-{StatusMessageModel.ToString(statusSeverity)}"));
var el = Driver.FindElement(By.CssSelector(className)) ?? Driver.WaitForElement(By.CssSelector(className));
IWebElement el;
try
{
el = Driver.FindElement(By.CssSelector(className));
}
catch (NoSuchElementException)
{
el = Driver.WaitForElement(By.CssSelector(className));
}
if (el is null)
throw new NoSuchElementException($"Unable to find {className}");
return el;