mirror of
https://github.com/LD-Reborn/Berufsschule_HAM.git
synced 2025-12-20 06:51:55 +00:00
Added TryRetryFindToast helper
This commit is contained in:
@@ -65,4 +65,35 @@ public static class AppHelper
|
|||||||
submit.Click();
|
submit.Click();
|
||||||
Thread.Sleep(250);
|
Thread.Sleep(250);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool TryRetryFindToast(ChromeDriver driver)
|
||||||
|
{
|
||||||
|
int retryCounter = 0;
|
||||||
|
retry:
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
IWebElement successToast = driver.FindElement(By.CssSelector("#toastContainer div.bg-success"));
|
||||||
|
if (successToast.Displayed)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception) { }
|
||||||
|
try
|
||||||
|
{
|
||||||
|
IWebElement failToast = driver.FindElement(By.CssSelector("#toastContainer div.bg-danger"));
|
||||||
|
if (failToast.Displayed)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception) { }
|
||||||
|
if (++retryCounter < 5)
|
||||||
|
{
|
||||||
|
Thread.Sleep(250);
|
||||||
|
goto retry;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -77,13 +77,7 @@ public class InventoryPageTests : IDisposable
|
|||||||
IWebElement okButton = _driver.FindElement(By.CssSelector("#viewAssetModal button.btn.btn-primary[data-bs-dismiss=\"modal\"]"));
|
IWebElement okButton = _driver.FindElement(By.CssSelector("#viewAssetModal button.btn.btn-primary[data-bs-dismiss=\"modal\"]"));
|
||||||
okButton.Click();
|
okButton.Click();
|
||||||
Thread.Sleep(500);
|
Thread.Sleep(500);
|
||||||
IWebElement successToast = _driver.FindElement(By.CssSelector("#toastContainer div.bg-success"));
|
Assert.True(AppHelper.TryRetryFindToast(_driver));
|
||||||
Assert.True(successToast.Displayed);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
IWebElement failToast = _driver.FindElement(By.CssSelector("#toastContainer div.bg-danger"));
|
|
||||||
Assert.False(failToast.Displayed);
|
|
||||||
} catch (Exception) {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@@ -104,13 +98,7 @@ public class InventoryPageTests : IDisposable
|
|||||||
IWebElement okButton = _driver.FindElement(By.CssSelector("#updateAssetModal button.btn.btn-warning[type=\"submit\"]"));
|
IWebElement okButton = _driver.FindElement(By.CssSelector("#updateAssetModal button.btn.btn-warning[type=\"submit\"]"));
|
||||||
okButton.Click();
|
okButton.Click();
|
||||||
Thread.Sleep(500);
|
Thread.Sleep(500);
|
||||||
IWebElement successToast = _driver.FindElement(By.CssSelector("#toastContainer div.bg-success"));
|
Assert.True(AppHelper.TryRetryFindToast(_driver));
|
||||||
Assert.True(successToast.Displayed);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
IWebElement failToast = _driver.FindElement(By.CssSelector("#toastContainer div.bg-danger"));
|
|
||||||
Assert.False(failToast.Displayed);
|
|
||||||
} catch (Exception) {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|||||||
Reference in New Issue
Block a user