mirror of
https://github.com/LD-Reborn/Berufsschule_HAM.git
synced 2025-12-20 06:51:55 +00:00
Replaced unreliable sleeps in TryRetryFindSuccessToast
This commit is contained in:
@@ -74,33 +74,8 @@ public static class AppHelper
|
|||||||
|
|
||||||
public static bool TryRetryFindSuccessToast(ChromeDriver driver)
|
public static bool TryRetryFindSuccessToast(ChromeDriver driver)
|
||||||
{
|
{
|
||||||
int retryCounter = 0;
|
Timeout(driver).Until(ExpectedConditions.ElementIsVisible(By.CssSelector("#toastContainer div.bg-success")));
|
||||||
retry:
|
return true;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool CheckboxGetState(IWebElement webElement)
|
public static bool CheckboxGetState(IWebElement webElement)
|
||||||
@@ -142,4 +117,9 @@ public static class AppHelper
|
|||||||
{
|
{
|
||||||
return new(driver, TimeSpan.FromSeconds(DefaultTimeout));
|
return new(driver, TimeSpan.FromSeconds(DefaultTimeout));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string GetRandomName()
|
||||||
|
{
|
||||||
|
return new string([.. Enumerable.Range(0, 8).Select(_ => (char)('a' + new Random().Next(26)))]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user