diff --git a/bellatrix.web/src/main/java/solutions/bellatrix/web/components/WebComponent.java b/bellatrix.web/src/main/java/solutions/bellatrix/web/components/WebComponent.java index 13b967b1..0668f5ed 100644 --- a/bellatrix.web/src/main/java/solutions/bellatrix/web/components/WebComponent.java +++ b/bellatrix.web/src/main/java/solutions/bellatrix/web/components/WebComponent.java @@ -118,9 +118,13 @@ public ComponentT as(Class compone public WebElement getWrappedElement() { try { - wrappedElement.isDisplayed(); // checking if getting property throws exception - return wrappedElement; - } catch (StaleElementReferenceException | NoSuchElementException | NullPointerException | ScriptTimeoutException ex ) { + if(wrappedElement != null) { + wrappedElement.isDisplayed(); // checking if getting property throws exception + return wrappedElement; + } else { + return findElement(); + } + } catch (Exception ex ) { return findElement(); } } diff --git a/bellatrix.web/src/main/java/solutions/bellatrix/web/waitstrategies/ToExistWaitStrategy.java b/bellatrix.web/src/main/java/solutions/bellatrix/web/waitstrategies/ToExistWaitStrategy.java index 00fbe9fa..4f320879 100644 --- a/bellatrix.web/src/main/java/solutions/bellatrix/web/waitstrategies/ToExistWaitStrategy.java +++ b/bellatrix.web/src/main/java/solutions/bellatrix/web/waitstrategies/ToExistWaitStrategy.java @@ -13,9 +13,7 @@ package solutions.bellatrix.web.waitstrategies; -import org.openqa.selenium.By; -import org.openqa.selenium.NoSuchElementException; -import org.openqa.selenium.SearchContext; +import org.openqa.selenium.*; import solutions.bellatrix.core.configuration.ConfigurationService; import solutions.bellatrix.web.configuration.WebSettings; @@ -42,7 +40,7 @@ private boolean elementExists(SearchContext searchContext, By by) { try { var element = findElement(searchContext, by); return element != null; - } catch (NoSuchElementException e) { + } catch (NoSuchElementException | StaleElementReferenceException | ElementNotInteractableException e) { return false; } }