diff options
author | Mavlushechka <mavlushechka@gmail.com> | 2022-09-22 00:15:33 +0500 |
---|---|---|
committer | Mavlushechka <mavlushechka@gmail.com> | 2022-09-22 00:15:33 +0500 |
commit | 6aae55e910771d388c5d198524f5872eee904307 (patch) | |
tree | 19690c08695f03c07c46ee1c06ec84214f60f299 | |
parent | 34088f3adb24cdf90b4f13eb1d38ec7072bb81a5 (diff) |
Add checking visibility of an element before finding the element in BaseElement class
-rw-r--r-- | src/main/java/com/mavlushechka/a1qa/elements/BaseElement.java | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/main/java/com/mavlushechka/a1qa/elements/BaseElement.java b/src/main/java/com/mavlushechka/a1qa/elements/BaseElement.java index 8a7408d..29666be 100644 --- a/src/main/java/com/mavlushechka/a1qa/elements/BaseElement.java +++ b/src/main/java/com/mavlushechka/a1qa/elements/BaseElement.java @@ -41,17 +41,13 @@ public abstract class BaseElement { } public boolean isVisible() { - WebElement webElement = find(); - LoggerUtils.info("Getting visibility of the \"" + name + "\" element."); - return WebDriverWaitFactory.createWebDriverWait().until(ExpectedConditions.visibilityOf(webElement)).isDisplayed(); + return WebDriverWaitFactory.createWebDriverWait().until(ExpectedConditions.visibilityOfElementLocated(locator)).isDisplayed(); } public boolean isInvisible() { - WebElement webElement = find(); - LoggerUtils.info("Getting invisibility of the \"" + name + "\" element."); - return WebDriverWaitFactory.createWebDriverWait().until(ExpectedConditions.invisibilityOf(webElement)); + return WebDriverWaitFactory.createWebDriverWait().until(ExpectedConditions.invisibilityOfElementLocated(locator)); } public String getName() { @@ -73,6 +69,7 @@ public abstract class BaseElement { } protected WebElement find() { + isVisible(); LoggerUtils.info("Finding the \"" + name + "\" element."); return WebDriverUtils.findElement(locator); } |