diff --git a/pom.xml b/pom.xml index bffa7e1245..7be92a2dbd 100644 --- a/pom.xml +++ b/pom.xml @@ -89,7 +89,7 @@ 1.58 3.1.0.M1 3.28.0-GA - 2.13.2 + 2.13.2.1 3.5.2 diff --git a/serenity-core/src/main/java/net/serenitybdd/core/pages/PageObject.java b/serenity-core/src/main/java/net/serenitybdd/core/pages/PageObject.java index f08bfb1009..f6f64313cd 100644 --- a/serenity-core/src/main/java/net/serenitybdd/core/pages/PageObject.java +++ b/serenity-core/src/main/java/net/serenitybdd/core/pages/PageObject.java @@ -456,7 +456,7 @@ public PageObject waitForTitleToAppear(final String expectedTitle) { } public WebDriverWait waitOnPage() { - return new WebDriverWait(driver, getWaitForTimeout().getSeconds()); + return new WebDriverWait(driver, getWaitForTimeout()); } public PageObject waitForTitleToDisappear(final String expectedTitle) { diff --git a/serenity-core/src/main/java/net/serenitybdd/core/pages/RenderedPageObjectView.java b/serenity-core/src/main/java/net/serenitybdd/core/pages/RenderedPageObjectView.java index b967db8742..555bdc4c9d 100644 --- a/serenity-core/src/main/java/net/serenitybdd/core/pages/RenderedPageObjectView.java +++ b/serenity-core/src/main/java/net/serenitybdd/core/pages/RenderedPageObjectView.java @@ -195,7 +195,7 @@ private boolean allElementsVisibleIn(List webElements) { * This method will wait until an element is present on the screen, though not necessarily visible. */ public WebElement waitForPresenceOf(final By byElementCriteria) { - WebDriverWait wait = new WebDriverWait(driver, waitForTimeout.getSeconds()); + WebDriverWait wait = new WebDriverWait(driver, waitForTimeout); return wait.until(presenceOfElementLocated(byElementCriteria)); } @@ -250,7 +250,7 @@ public void waitForText(final String expectedText) { } public WebDriverWait thenWait() { - return new WebDriverWait(driver, getWaitForTimeout().getSeconds()); + return new WebDriverWait(driver, getWaitForTimeout()); } diff --git a/serenity-core/src/main/java/net/serenitybdd/core/pages/WebElementFacadeImpl.java b/serenity-core/src/main/java/net/serenitybdd/core/pages/WebElementFacadeImpl.java index 992986fabb..1e831b0943 100644 --- a/serenity-core/src/main/java/net/serenitybdd/core/pages/WebElementFacadeImpl.java +++ b/serenity-core/src/main/java/net/serenitybdd/core/pages/WebElementFacadeImpl.java @@ -373,7 +373,7 @@ public boolean isVisible() { return element.isDisplayed(); } - } catch (ElementNotVisibleException | NoSuchElementException | StaleElementReferenceException | TimeoutException e) { + } catch (ElementNotInteractableException | NoSuchElementException | StaleElementReferenceException | TimeoutException e) { return false; } } @@ -910,7 +910,7 @@ private boolean elementIsPresent() { } element.isDisplayed(); return true; - } catch (ElementNotVisibleException e) { + } catch (ElementNotInteractableException e) { return true; } catch (NotFoundException | ElementNotFoundAfterTimeoutError e) { return false; diff --git a/serenity-core/src/main/java/net/serenitybdd/core/pages/WebElementFacadeWait.java b/serenity-core/src/main/java/net/serenitybdd/core/pages/WebElementFacadeWait.java index a19bd3104f..b72a08279f 100644 --- a/serenity-core/src/main/java/net/serenitybdd/core/pages/WebElementFacadeWait.java +++ b/serenity-core/src/main/java/net/serenitybdd/core/pages/WebElementFacadeWait.java @@ -4,6 +4,8 @@ import org.openqa.selenium.support.ui.ExpectedCondition; import org.openqa.selenium.support.ui.WebDriverWait; +import java.time.Duration; + public class WebElementFacadeWait { PageObject page; private final long timeoutInSeconds; @@ -37,6 +39,6 @@ public WebElementFacadeWait pollingEvery(long sleepInMillis) { } public WebElementFacade until(ExpectedCondition isTrue) { - return page.element(new WebDriverWait(page.getDriver(), timeoutInSeconds).until(isTrue)); + return page.element(new WebDriverWait(page.getDriver(), Duration.ofSeconds(timeoutInSeconds)).until(isTrue)); } } diff --git a/serenity-core/src/main/java/net/serenitybdd/core/pages/WebElementResolverByElementLocator.java b/serenity-core/src/main/java/net/serenitybdd/core/pages/WebElementResolverByElementLocator.java index 786bbc18ec..19c28b9776 100644 --- a/serenity-core/src/main/java/net/serenitybdd/core/pages/WebElementResolverByElementLocator.java +++ b/serenity-core/src/main/java/net/serenitybdd/core/pages/WebElementResolverByElementLocator.java @@ -4,7 +4,7 @@ import net.thucydides.core.annotations.locators.WithConfigurableTimeout; import net.thucydides.core.steps.StepEventBus; import net.thucydides.core.webdriver.ConfigurableTimeouts; -import org.openqa.selenium.ElementNotVisibleException; +import org.openqa.selenium.ElementNotInteractableException; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.pagefactory.ElementLocator; @@ -40,7 +40,7 @@ public List resolveAllForDriver(WebDriver driver) { private void ensureVisibilityOf(WebElement resolvedELement) { if (resolvedELement == null) { - throw new ElementNotVisibleException(locator.toString()); + throw new ElementNotInteractableException(locator.toString()); } } diff --git a/serenity-core/src/main/java/net/thucydides/core/annotations/locators/SmartAjaxElementLocator.java b/serenity-core/src/main/java/net/thucydides/core/annotations/locators/SmartAjaxElementLocator.java index b34d0e894c..21eb1a39b4 100644 --- a/serenity-core/src/main/java/net/thucydides/core/annotations/locators/SmartAjaxElementLocator.java +++ b/serenity-core/src/main/java/net/thucydides/core/annotations/locators/SmartAjaxElementLocator.java @@ -156,7 +156,7 @@ public WebElement ajaxFindElement() { try { return loadingElement.get().getElement(); } catch (ElementNotVisibleAfterTimeoutError notVisible) { - throw new ElementNotVisibleException( + throw new ElementNotInteractableException( String.format("Timed out after %d seconds. %s", annotatedTimeoutInSeconds.orElse(getTimeOutInSeconds()), notVisible.getMessage()), notVisible.getCause()); } catch (Error e) { @@ -314,4 +314,4 @@ public String toString() { public String toString() { return (field != null) ? field.getDeclaringClass().getSimpleName() + "." + field.getName() : ""; } -} \ No newline at end of file +} diff --git a/serenity-core/src/main/java/net/thucydides/core/webdriver/exceptions/ElementShouldBeVisibleException.java b/serenity-core/src/main/java/net/thucydides/core/webdriver/exceptions/ElementShouldBeVisibleException.java index da08277043..02f94524d6 100644 --- a/serenity-core/src/main/java/net/thucydides/core/webdriver/exceptions/ElementShouldBeVisibleException.java +++ b/serenity-core/src/main/java/net/thucydides/core/webdriver/exceptions/ElementShouldBeVisibleException.java @@ -1,9 +1,9 @@ package net.thucydides.core.webdriver.exceptions; import net.serenitybdd.core.exceptions.CausesAssertionFailure; -import org.openqa.selenium.ElementNotVisibleException; +import org.openqa.selenium.ElementNotInteractableException; -public class ElementShouldBeVisibleException extends ElementNotVisibleException implements CausesAssertionFailure { +public class ElementShouldBeVisibleException extends ElementNotInteractableException implements CausesAssertionFailure { public ElementShouldBeVisibleException(String message, Throwable cause) { super(message, cause); } diff --git a/serenity-core/src/main/java/net/thucydides/core/webdriver/stubs/TargetLocatorStub.java b/serenity-core/src/main/java/net/thucydides/core/webdriver/stubs/TargetLocatorStub.java index a0e80f3056..8c6b819dd4 100644 --- a/serenity-core/src/main/java/net/thucydides/core/webdriver/stubs/TargetLocatorStub.java +++ b/serenity-core/src/main/java/net/thucydides/core/webdriver/stubs/TargetLocatorStub.java @@ -4,7 +4,7 @@ public class TargetLocatorStub implements WebDriver.TargetLocator { - private WebDriver webDriver; + private final WebDriver webDriver; public TargetLocatorStub(WebDriver webDriver) { this.webDriver = webDriver; @@ -47,7 +47,7 @@ public WebDriver defaultContent() { @Override public WebElement activeElement() { - throw new ElementNotVisibleException("No active element found (a previous step has failed)"); + throw new ElementNotInteractableException("No active element found (a previous step has failed)"); } @Override diff --git a/serenity-core/src/test/groovy/net/serenitybdd/core/pages/integration/WhenManagingWebdriverTimeouts.groovy b/serenity-core/src/test/groovy/net/serenitybdd/core/pages/integration/WhenManagingWebdriverTimeouts.groovy index 74b7ece86d..f044ddbad5 100644 --- a/serenity-core/src/test/groovy/net/serenitybdd/core/pages/integration/WhenManagingWebdriverTimeouts.groovy +++ b/serenity-core/src/test/groovy/net/serenitybdd/core/pages/integration/WhenManagingWebdriverTimeouts.groovy @@ -83,7 +83,7 @@ class WhenManagingWebdriverTimeouts extends Specification { when: "We access the field" page.slowLoadingField.isDisplayed() then: "An error should be thrown" - thrown(org.openqa.selenium.ElementNotVisibleException) + thrown(org.openqa.selenium.ElementNotInteractableException) } def "Slow loading fields should not wait once a step has failed"() { @@ -99,7 +99,7 @@ class WhenManagingWebdriverTimeouts extends Specification { stopwatch.start() page.verySlowLoadingField.isDisplayed() then: "No error should be thrown" - notThrown(org.openqa.selenium.ElementNotVisibleException) + notThrown(org.openqa.selenium.ElementNotInteractableException) and: "the response should be returned instantly" stopwatch.stop() < 100 } diff --git a/serenity-core/src/test/java/net/thucydides/core/pages/integration/CheckingFieldContentWithTheFluentElementAPI.java b/serenity-core/src/test/java/net/thucydides/core/pages/integration/CheckingFieldContentWithTheFluentElementAPI.java index c7c67b4329..b887b91d11 100644 --- a/serenity-core/src/test/java/net/thucydides/core/pages/integration/CheckingFieldContentWithTheFluentElementAPI.java +++ b/serenity-core/src/test/java/net/thucydides/core/pages/integration/CheckingFieldContentWithTheFluentElementAPI.java @@ -167,7 +167,7 @@ public void should_pass_immediately_if_waiting_for_field_that_is_present() { page.element(page.firstName).waitUntilVisible(); } - @Test(expected = ElementNotVisibleException.class) + @Test(expected = ElementNotInteractableException.class) public void should_throw_expection_if_waiting_for_field_that_does_not_appear() { page.setWaitForTimeout(500); assertThat(page.element(page.hiddenField).isCurrentlyVisible(), is(false)); diff --git a/serenity-core/src/test/java/net/thucydides/core/webdriver/WhenLocatingWebElements.java b/serenity-core/src/test/java/net/thucydides/core/webdriver/WhenLocatingWebElements.java index 7aca3ab898..3752835205 100644 --- a/serenity-core/src/test/java/net/thucydides/core/webdriver/WhenLocatingWebElements.java +++ b/serenity-core/src/test/java/net/thucydides/core/webdriver/WhenLocatingWebElements.java @@ -12,7 +12,7 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.openqa.selenium.By; -import org.openqa.selenium.ElementNotVisibleException; +import org.openqa.selenium.ElementNotInteractableException; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; @@ -74,7 +74,7 @@ public void should_find_element_immediately_if_a_previous_step_has_failed() thro @Test public void should_wait_for_find_element_immediately_if_no_previous_step_has_failed() { - expectedException.expect(ElementNotVisibleException.class); + expectedException.expect(ElementNotInteractableException.class); SmartAjaxElementLocator locator = new SmartAjaxElementLocator(driver, field, MobilePlatform.NONE); locator.findElement(); } diff --git a/serenity-core/src/test/java/net/thucydides/core/webdriver/WhenUsingADisabledWebDriverFacade.java b/serenity-core/src/test/java/net/thucydides/core/webdriver/WhenUsingADisabledWebDriverFacade.java index 0beb07f444..be3335e3b2 100644 --- a/serenity-core/src/test/java/net/thucydides/core/webdriver/WhenUsingADisabledWebDriverFacade.java +++ b/serenity-core/src/test/java/net/thucydides/core/webdriver/WhenUsingADisabledWebDriverFacade.java @@ -5,11 +5,13 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.openqa.selenium.By; -import org.openqa.selenium.ElementNotVisibleException; +import org.openqa.selenium.ElementNotInteractableException; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; +import java.time.Duration; + import static java.util.concurrent.TimeUnit.SECONDS; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; @@ -94,7 +96,7 @@ public void alerts_should_be_ignored() { webDriverFacade.switchTo().alert().sendKeys("abc"); } - @Test(expected = ElementNotVisibleException.class) + @Test(expected = ElementNotInteractableException.class) public void switchTo_web_element_should_throw_element_not_visible() { webDriverFacade.switchTo().activeElement(); } @@ -116,7 +118,7 @@ public void cookies_should_be_ignored() { @Test public void manage_timeouts_should_be_ignored() { - webDriverFacade.manage().timeouts().implicitlyWait(100, SECONDS).setScriptTimeout(100, SECONDS); + webDriverFacade.manage().timeouts().implicitlyWait(Duration.ofSeconds(100)).scriptTimeout(Duration.ofSeconds(100)); } @Test diff --git a/serenity-cucumber/src/test/java/net/serenitybdd/cucumber/integration/steps/thucydides/SomeSeleniumSteps.java b/serenity-cucumber/src/test/java/net/serenitybdd/cucumber/integration/steps/thucydides/SomeSeleniumSteps.java index 0e441ff66d..e1ff67b511 100644 --- a/serenity-cucumber/src/test/java/net/serenitybdd/cucumber/integration/steps/thucydides/SomeSeleniumSteps.java +++ b/serenity-cucumber/src/test/java/net/serenitybdd/cucumber/integration/steps/thucydides/SomeSeleniumSteps.java @@ -8,7 +8,7 @@ import net.thucydides.core.annotations.Steps; import net.thucydides.core.pages.Pages; import net.thucydides.core.webdriver.WebDriverFacade; -import org.openqa.selenium.ElementNotVisibleException; +import org.openqa.selenium.ElementNotInteractableException; import org.openqa.selenium.WebDriver; import static org.hamcrest.MatcherAssert.assertThat; @@ -81,7 +81,7 @@ public void andIShouldBeUsing(String driverName) { @Given("the scenario throws an exception") public void throwAnException() { - throw new ElementNotVisibleException("Oops"); + throw new ElementNotInteractableException("Oops"); } diff --git a/serenity-junit/src/test/java/net/thucydides/samples/SampleScenarioSteps.java b/serenity-junit/src/test/java/net/thucydides/samples/SampleScenarioSteps.java index eb1094aebb..b9ca599eee 100644 --- a/serenity-junit/src/test/java/net/thucydides/samples/SampleScenarioSteps.java +++ b/serenity-junit/src/test/java/net/thucydides/samples/SampleScenarioSteps.java @@ -9,7 +9,7 @@ import net.thucydides.junit.runners.ThucydidesRunner; import org.junit.Assume; import org.junit.Ignore; -import org.openqa.selenium.ElementNotVisibleException; +import org.openqa.selenium.ElementNotInteractableException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -218,7 +218,7 @@ public void data_driven_test_step_that_fails() { @Step public void data_driven_test_step_that_breaks() { if (Integer.parseInt(age) > 35) { - throw new ElementNotVisibleException("A webdriver issue"); + throw new ElementNotInteractableException("A webdriver issue"); } } diff --git a/serenity-junit5/src/test/java/net/thucydides/samples/SampleScenarioSteps.java b/serenity-junit5/src/test/java/net/thucydides/samples/SampleScenarioSteps.java index d9553e5c2e..ae0bb846d8 100644 --- a/serenity-junit5/src/test/java/net/thucydides/samples/SampleScenarioSteps.java +++ b/serenity-junit5/src/test/java/net/thucydides/samples/SampleScenarioSteps.java @@ -5,22 +5,16 @@ import net.thucydides.core.annotations.Pending; import net.thucydides.core.annotations.Step; import net.thucydides.core.annotations.Steps; -import net.thucydides.core.pages.Pages; -import net.thucydides.core.steps.ScenarioSteps; -import org.junit.Assume; import org.junit.Ignore; import org.junit.jupiter.api.Assumptions; -import org.openqa.selenium.ElementNotVisibleException; +import org.openqa.selenium.ElementNotInteractableException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.concurrent.ThreadLocalRandom; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.isEmptyString; -import static org.hamcrest.Matchers.lessThan; -import static org.hamcrest.Matchers.not; +import static org.hamcrest.Matchers.*; @SuppressWarnings("serial") public class SampleScenarioSteps extends UIInteractionSteps { @@ -235,7 +229,7 @@ public void data_driven_test_step_that_fails(String age) { @Step public void data_driven_test_step_that_breaks(String age) { if (Integer.parseInt(age) > 35) { - throw new ElementNotVisibleException("A webdriver issue"); + throw new ElementNotInteractableException("A webdriver issue"); } } diff --git a/serenity-model/src/main/java/net/thucydides/core/model/TestStep.java b/serenity-model/src/main/java/net/thucydides/core/model/TestStep.java index 576f9f3b64..7559269ac4 100644 --- a/serenity-model/src/main/java/net/thucydides/core/model/TestStep.java +++ b/serenity-model/src/main/java/net/thucydides/core/model/TestStep.java @@ -658,8 +658,8 @@ private boolean thisIsANew(ScreenshotAndHtmlSource screenshotAndHtmlSource) { if (screenshots.isEmpty()) { return true; } else { - ScreenshotAndHtmlSource latestScreenshotAndHtmlSource = screenshots.get(screenshots.size() - 1); - return !latestScreenshotAndHtmlSource.equals(screenshotAndHtmlSource); + ScreenshotAndHtmlSource previousScreenshot = screenshots.get(screenshots.size() - 1); + return !screenshotAndHtmlSource.getScreenshotName().equals(previousScreenshot.getScreenshotName()); } } diff --git a/serenity-model/src/main/java/net/thucydides/core/screenshots/ScreenshotAndHtmlSource.java b/serenity-model/src/main/java/net/thucydides/core/screenshots/ScreenshotAndHtmlSource.java index 4ae995726f..44fcd3fb88 100644 --- a/serenity-model/src/main/java/net/thucydides/core/screenshots/ScreenshotAndHtmlSource.java +++ b/serenity-model/src/main/java/net/thucydides/core/screenshots/ScreenshotAndHtmlSource.java @@ -13,21 +13,24 @@ public class ScreenshotAndHtmlSource implements Comparable