diff --git a/testing-modules/selenium-2/src/test/java/com/baeldung/selenium/wait/ExplicitWaitLiveTest.java b/testing-modules/selenium-2/src/test/java/com/baeldung/selenium/wait/ExplicitWaitLiveTest.java index a48857f31d..d9627c2ce2 100644 --- a/testing-modules/selenium-2/src/test/java/com/baeldung/selenium/wait/ExplicitWaitLiveTest.java +++ b/testing-modules/selenium-2/src/test/java/com/baeldung/selenium/wait/ExplicitWaitLiveTest.java @@ -11,6 +11,7 @@ import org.junit.jupiter.api.Test; import org.openqa.selenium.By; import org.openqa.selenium.ElementNotInteractableException; import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions; import org.openqa.selenium.support.ui.ExpectedConditions; @@ -49,10 +50,8 @@ final class ExplicitWaitLiveTest { @Test void givenPage_whenNavigatingWithoutExplicitWait_thenElementNotInteractable() { driver.navigate().to("https://www.baeldung.com/"); - - driver.findElement(LOCATOR_ABOUT).click(); - - assertThrows(ElementNotInteractableException.class, () -> driver.findElement(LOCATOR_ABOUT_BAELDUNG).click()); + WebElement about = driver.findElement(LOCATOR_ABOUT_BAELDUNG); + assertThrows(ElementNotInteractableException.class, about::click); } @Test diff --git a/testing-modules/selenium-2/src/test/java/com/baeldung/selenium/wait/FluentWaitLiveTest.java b/testing-modules/selenium-2/src/test/java/com/baeldung/selenium/wait/FluentWaitLiveTest.java index 51e14ad210..9de462690d 100644 --- a/testing-modules/selenium-2/src/test/java/com/baeldung/selenium/wait/FluentWaitLiveTest.java +++ b/testing-modules/selenium-2/src/test/java/com/baeldung/selenium/wait/FluentWaitLiveTest.java @@ -11,6 +11,7 @@ import org.junit.jupiter.api.Test; import org.openqa.selenium.By; import org.openqa.selenium.ElementNotInteractableException; import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions; import org.openqa.selenium.support.ui.ExpectedConditions; @@ -53,10 +54,8 @@ final class FluentWaitLiveTest { @Test void givenPage_whenNavigatingWithoutFluentWait_thenElementNotInteractable() { driver.navigate().to("https://www.baeldung.com/"); - - driver.findElement(LOCATOR_ABOUT).click(); - - assertThrows(ElementNotInteractableException.class, () -> driver.findElement(LOCATOR_ABOUT_BAELDUNG).click()); + WebElement about = driver.findElement(LOCATOR_ABOUT_BAELDUNG); + assertThrows(ElementNotInteractableException.class, about::click); } @Test