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,34 +74,9 @@ public static class AppHelper
|
||||
|
||||
public static bool TryRetryFindSuccessToast(ChromeDriver driver)
|
||||
{
|
||||
int retryCounter = 0;
|
||||
retry:
|
||||
try
|
||||
{
|
||||
|
||||
IWebElement successToast = driver.FindElement(By.CssSelector("#toastContainer div.bg-success"));
|
||||
if (successToast.Displayed)
|
||||
{
|
||||
Timeout(driver).Until(ExpectedConditions.ElementIsVisible(By.CssSelector("#toastContainer div.bg-success")));
|
||||
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)
|
||||
{
|
||||
@@ -142,4 +117,9 @@ public static class AppHelper
|
||||
{
|
||||
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