From 156ddd24fa0b02a77363af92f8ba8f7d182620b4 Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Tue, 5 Oct 2021 15:47:57 +0900 Subject: [PATCH] Make CanUsePayjoinForTopUp more resilient --- BTCPayServer.Tests/Extensions.cs | 6 ++++-- BTCPayServer.Tests/PayJoinTests.cs | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/BTCPayServer.Tests/Extensions.cs b/BTCPayServer.Tests/Extensions.cs index cca9a6de9..b35c89a10 100644 --- a/BTCPayServer.Tests/Extensions.cs +++ b/BTCPayServer.Tests/Extensions.cs @@ -49,12 +49,14 @@ namespace BTCPayServer.Tests } // Sometimes, selenium is flaky... - public static IWebElement FindElementUntilNotStaled(this IWebDriver driver, By by) + public static IWebElement FindElementUntilNotStaled(this IWebDriver driver, By by, Action act) { retry: try { - return driver.FindElement(by); + var el = driver.FindElement(by); + act(el); + return el; } catch (StaleElementReferenceException) { diff --git a/BTCPayServer.Tests/PayJoinTests.cs b/BTCPayServer.Tests/PayJoinTests.cs index ef29a431a..95a25704a 100644 --- a/BTCPayServer.Tests/PayJoinTests.cs +++ b/BTCPayServer.Tests/PayJoinTests.cs @@ -255,8 +255,8 @@ namespace BTCPayServer.Tests s.Driver.FindElement(By.Id("bip21parse")).Click(); s.Driver.SwitchTo().Alert().SendKeys(bip21); s.Driver.SwitchTo().Alert().Accept(); - s.Driver.FindElementUntilNotStaled(By.Id("Outputs_0__Amount")).Clear(); - s.Driver.FindElementUntilNotStaled(By.Id("Outputs_0__Amount")).SendKeys("0.023"); + s.Driver.FindElementUntilNotStaled(By.Id("Outputs_0__Amount"), we => we.Clear()); + s.Driver.FindElementUntilNotStaled(By.Id("Outputs_0__Amount"), we => we.SendKeys("0.023")); s.Driver.FindElement(By.Id("SignTransaction")).Click();