From 5b5e921b221ae526c757c537c6ebea8018f0f868 Mon Sep 17 00:00:00 2001 From: Ehsan Sasanianno Date: Mon, 17 Jul 2023 17:57:08 +0200 Subject: [PATCH] fix failing tests in selenium-2 due to website change (#14422) --- .../com/baeldung/selenium/wait/ExplicitWaitLiveTest.java | 7 +++---- .../com/baeldung/selenium/wait/FluentWaitLiveTest.java | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) 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