return Assertions.fail() in catch block of custom waiters method
This commit is contained in:
parent
16061ec4fc
commit
12041ee6e2
@ -16,7 +16,6 @@
|
||||
package org.thingsboard.server.msa.ui.base;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.JavascriptExecutor;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
@ -34,7 +33,8 @@ import java.util.UUID;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Slf4j
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
abstract public class AbstractBasePage {
|
||||
public static final long WAIT_TIMEOUT = TimeUnit.SECONDS.toMillis(30);
|
||||
protected WebDriver driver;
|
||||
@ -59,8 +59,7 @@ abstract public class AbstractBasePage {
|
||||
try {
|
||||
return wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(locator)));
|
||||
} catch (WebDriverException e) {
|
||||
log.error("No visibility element: " + locator);
|
||||
return null;
|
||||
return fail("No visibility element: " + locator);
|
||||
}
|
||||
}
|
||||
|
||||
@ -68,8 +67,7 @@ abstract public class AbstractBasePage {
|
||||
try {
|
||||
return wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath(locator)));
|
||||
} catch (WebDriverException e) {
|
||||
log.error("No presence element: " + locator);
|
||||
return null;
|
||||
return fail("No presence element: " + locator);
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,8 +75,7 @@ abstract public class AbstractBasePage {
|
||||
try {
|
||||
return wait.until(ExpectedConditions.elementToBeClickable(By.xpath(locator)));
|
||||
} catch (WebDriverException e) {
|
||||
log.error("No clickable element: " + locator);
|
||||
return null;
|
||||
return fail("No clickable element: " + locator);
|
||||
}
|
||||
}
|
||||
|
||||
@ -87,8 +84,7 @@ abstract public class AbstractBasePage {
|
||||
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(locator)));
|
||||
return driver.findElements(By.xpath(locator));
|
||||
} catch (WebDriverException e) {
|
||||
log.error("No visibility elements: " + locator);
|
||||
return null;
|
||||
return fail("No visibility elements: " + locator);
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,8 +93,7 @@ abstract public class AbstractBasePage {
|
||||
wait.until(ExpectedConditions.elementToBeClickable(By.xpath(locator)));
|
||||
return driver.findElements(By.xpath(locator));
|
||||
} catch (WebDriverException e) {
|
||||
log.error("No clickable elements: " + locator);
|
||||
return null;
|
||||
return fail("No clickable elements: " + locator);
|
||||
}
|
||||
}
|
||||
|
||||
@ -106,7 +101,7 @@ abstract public class AbstractBasePage {
|
||||
try {
|
||||
wait.until(ExpectedConditions.urlContains(urlPath));
|
||||
} catch (WebDriverException e) {
|
||||
log.error("This URL path is missing");
|
||||
fail("This URL path is missing");
|
||||
}
|
||||
}
|
||||
|
||||
@ -122,7 +117,7 @@ abstract public class AbstractBasePage {
|
||||
try {
|
||||
return wait.until(ExpectedConditions.not(ExpectedConditions.visibilityOfElementLocated(By.xpath(locator))));
|
||||
} catch (WebDriverException e) {
|
||||
throw new AssertionError("Element is present");
|
||||
return fail("Element is present");
|
||||
}
|
||||
}
|
||||
|
||||
@ -130,7 +125,7 @@ abstract public class AbstractBasePage {
|
||||
try {
|
||||
return wait.until(ExpectedConditions.not(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath(locator))));
|
||||
} catch (WebDriverException e) {
|
||||
throw new AssertionError("Elements is present");
|
||||
return fail("Elements is present");
|
||||
}
|
||||
}
|
||||
|
||||
@ -138,7 +133,7 @@ abstract public class AbstractBasePage {
|
||||
try {
|
||||
wait.until(ExpectedConditions.numberOfWindowsToBe(tabNumber));
|
||||
} catch (WebDriverException e) {
|
||||
log.error("No tabs with this number");
|
||||
fail("No tabs with this number: " + tabNumber);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user