diff --git a/BTCPayServer.Tests/CheckoutUITests.cs b/BTCPayServer.Tests/CheckoutUITests.cs index e41104dab..05f23f3c0 100644 --- a/BTCPayServer.Tests/CheckoutUITests.cs +++ b/BTCPayServer.Tests/CheckoutUITests.cs @@ -1,13 +1,10 @@ using System; -using System.Linq; using System.Threading.Tasks; -using BTCPayServer.Lightning; using BTCPayServer.Payments; using BTCPayServer.Tests.Logging; using BTCPayServer.Views.Stores; using NBitcoin; using OpenQA.Selenium; -using OpenQA.Selenium.Support.UI; using Xunit; using Xunit.Abstractions; @@ -166,30 +163,4 @@ namespace BTCPayServer.Tests } } } - - public static class SeleniumExtensions - { - /// - /// Utility method to wait until timeout for element to be present (optionally displayed) - /// - /// Wait context - /// How we search for element - /// Flag to wait for element to be displayed or just present - /// How long to wait for element to be present/displayed - /// Element we were waiting for - public static IWebElement WaitForElement(this IWebDriver context, By by, bool displayed = true, uint timeout = 3) - { - var wait = new DefaultWait(context); - wait.Timeout = TimeSpan.FromSeconds(timeout); - wait.IgnoreExceptionTypes(typeof(NoSuchElementException)); - return wait.Until(ctx => - { - var elem = ctx.FindElement(by); - if (displayed && !elem.Displayed) - return null; - - return elem; - }); - } - } } diff --git a/BTCPayServer.Tests/Extensions.cs b/BTCPayServer.Tests/Extensions.cs index 4976f59e6..78a8cb3b6 100644 --- a/BTCPayServer.Tests/Extensions.cs +++ b/BTCPayServer.Tests/Extensions.cs @@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; using Newtonsoft.Json.Serialization; using OpenQA.Selenium; +using OpenQA.Selenium.Support.UI; using Xunit; namespace BTCPayServer.Tests @@ -31,6 +32,29 @@ namespace BTCPayServer.Tests { element.SendKeys(Keys.Return); } + + /// + /// Utility method to wait until timeout for element to be present (optionally displayed) + /// + /// Wait context + /// How we search for element + /// Flag to wait for element to be displayed or just present + /// How long to wait for element to be present/displayed + /// Element we were waiting for + public static IWebElement WaitForElement(this IWebDriver context, By by, bool displayed = true, uint timeout = 10) + { + var wait = new DefaultWait(context); + wait.Timeout = TimeSpan.FromSeconds(timeout); + wait.IgnoreExceptionTypes(typeof(NoSuchElementException)); + return wait.Until(ctx => + { + var elem = ctx.FindElement(by); + if (displayed && !elem.Displayed) + return null; + + return elem; + }); + } public static void AssertNoError(this IWebDriver driver) { try