From 576adf4cc2c8af0f826d8c39bed732819f5566ab Mon Sep 17 00:00:00 2001 From: gkunze Date: Mon, 21 Jun 2021 17:08:10 +0200 Subject: [PATCH] #148 Expanded test fo waitUntil and waitWhile --- .../neodymium/util/SelenideAddonsTest.java | 51 ++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/xceptance/neodymium/util/SelenideAddonsTest.java b/src/test/java/com/xceptance/neodymium/util/SelenideAddonsTest.java index 3bea57cec..953c52efa 100644 --- a/src/test/java/com/xceptance/neodymium/util/SelenideAddonsTest.java +++ b/src/test/java/com/xceptance/neodymium/util/SelenideAddonsTest.java @@ -739,7 +739,56 @@ public void testOptionalWaitWhileWithDefaultTimeout() privacyDialog.find(".btn-link").click(); // wait until the privacy dialog is hidden - isHidden = SelenideAddons.optionalWaitWhileCondition(privacyDialog, visible, Neodymium.configuration().optionalElementRetryTimeout()); + isHidden = SelenideAddons.optionalWaitWhileCondition(privacyDialog, visible); + Assert.assertTrue("the privacy message dialog remained visible during the timeframe", isHidden); + } + + private long customPollingInterval = 3000; + + @Test + public void testOptionalWaitUntilWithTimeoutAndPollingInterval() + { + openBlogPage(); + + // wait until the optional privacy dialog is visible + SelenideElement privacyDialog = $("#privacy-message"); + boolean isVisible = SelenideAddons.optionalWaitUntilCondition(privacyDialog, visible, customWaitingTime, customPollingInterval); + Assert.assertTrue("the privacy message dialog was not found within the timeframe", isVisible); + + // try wait until the optional privacy dialog is hidden, which will fail + long startTime = new Date().getTime(); + boolean isHidden = SelenideAddons.optionalWaitUntilCondition(privacyDialog, hidden, customWaitingTime, customPollingInterval); + long endTime = new Date().getTime(); + + // check that the is false as is expected + Assert.assertFalse("the privacy message dialog was unexpectedly hidden during the timeframe", isHidden); + + validateTimeWithinRange(startTime, endTime, + Neodymium.configuration().optionalElementRetryCount() * Neodymium.configuration().optionalElementRetryTimeout()); + } + + @Test + public void testOptionalWaitWhileWithTimeoutAndPollingInterval() + { + openBlogPage(); + + // wait until the optional privacy dialog is not visible anymore, which will fail + SelenideElement privacyDialog = $("#privacy-message").shouldBe(visible); + long startTime = new Date().getTime(); + boolean isHidden = SelenideAddons.optionalWaitWhileCondition(privacyDialog, visible, customWaitingTime, customPollingInterval); + long endTime = new Date().getTime(); + + // check that the result is false as expected + Assert.assertFalse("the privacy message dialog was unexpectedly hidden during the timeframe", isHidden); + + validateTimeWithinRange(startTime, endTime, + Neodymium.configuration().optionalElementRetryCount() * Neodymium.configuration().optionalElementRetryTimeout()); + + // click the opt out button + privacyDialog.find(".btn-link").click(); + + // wait until the privacy dialog is hidden + isHidden = SelenideAddons.optionalWaitWhileCondition(privacyDialog, visible, customWaitingTime, customPollingInterval); Assert.assertTrue("the privacy message dialog remained visible during the timeframe", isHidden); } }