diff options
author | Mavlushechka <mavlushechka@gmail.com> | 2022-09-22 00:55:08 +0500 |
---|---|---|
committer | Mavlushechka <mavlushechka@gmail.com> | 2022-09-22 00:55:08 +0500 |
commit | 28c1d2972e31012a8040d6b42a81ee21d988a476 (patch) | |
tree | 1b0529b1525210981b9dc770fd72364d320476a5 /src/main/java/com | |
parent | 4d09a3fe0610acdac4d65ba858e771afc6fc062c (diff) |
Add checking visibility of an element before finding the element in the BaseElement class
Diffstat (limited to 'src/main/java/com')
-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); } |