From 1ffecbed21669176e7c5f61f12ce782d13bdba74 Mon Sep 17 00:00:00 2001 From: "Daniel.Rey" Date: Mon, 24 Oct 2016 12:20:26 +0200 Subject: [PATCH] execute navigateTo automatically for every test #11 - added test for enforceNavigateTo --- .../extensions/aem/AemTweaksSpec.scala | 6 ++--- .../integration/js/AjaxSpec.scala | 6 ++--- .../navigation/EnforceNavigateTo.scala | 23 +++++++++++++++++++ 3 files changed, 29 insertions(+), 6 deletions(-) create mode 100755 integration_test/src/it/scala/org/scalawebtest/integration/navigation/EnforceNavigateTo.scala diff --git a/integration_test/src/it/scala/org/scalawebtest/integration/extensions/aem/AemTweaksSpec.scala b/integration_test/src/it/scala/org/scalawebtest/integration/extensions/aem/AemTweaksSpec.scala index 20213e3..83a4838 100755 --- a/integration_test/src/it/scala/org/scalawebtest/integration/extensions/aem/AemTweaksSpec.scala +++ b/integration_test/src/it/scala/org/scalawebtest/integration/extensions/aem/AemTweaksSpec.scala @@ -1,6 +1,6 @@ package org.scalawebtest.integration.extensions.aem -import org.scalatest.time.{Seconds, Span} +import org.scalatest.time.SpanSugar._ import org.scalawebtest.aem.AemTweaks import org.scalawebtest.aem.WcmMode.DISABLED import org.scalawebtest.core.gauge.Gauge.fit @@ -14,8 +14,8 @@ class AemTweaksSpec extends ScalaWebTestBaseSpec with AemTweaks { path = "/cookieVisualizing.jsp" "When wcmmode DISABLED is select webBrowser" should "send the according cookie" in { - implicitlyWait(Span(1, Seconds)) - eventually(timeout(Span(1, Seconds))) { + implicitlyWait(1 second) + eventually(timeout(1 second)) { fit(
  • @contains wcmmode
  • ) } } diff --git a/integration_test/src/it/scala/org/scalawebtest/integration/js/AjaxSpec.scala b/integration_test/src/it/scala/org/scalawebtest/integration/js/AjaxSpec.scala index eabadbd..2ea6e42 100755 --- a/integration_test/src/it/scala/org/scalawebtest/integration/js/AjaxSpec.scala +++ b/integration_test/src/it/scala/org/scalawebtest/integration/js/AjaxSpec.scala @@ -14,7 +14,7 @@ */ package org.scalawebtest.integration.js -import org.scalatest.time.{Seconds, Span} +import org.scalatest.time.SpanSugar._ import org.scalawebtest.core.gauge.Gauge.fits import org.scalawebtest.integration.ScalaWebTestBaseSpec @@ -23,12 +23,12 @@ class AjaxSpec extends ScalaWebTestBaseSpec { config.enableJavaScript(throwOnError = true) "A simple webpage loading content with JS" should "be correctly interpreted by HtmlUnit" in { - eventually(timeout(Span(1, Seconds))) { + eventually(timeout(1 second)) { container.text should include("Text loaded with JavaScript") } } it should "work with CheckingGauge" in { - eventually(timeout(Span(1, Seconds))) { + eventually(timeout(1 second)) { fits(
    Text loaded with JavaScript
    ) } } diff --git a/integration_test/src/it/scala/org/scalawebtest/integration/navigation/EnforceNavigateTo.scala b/integration_test/src/it/scala/org/scalawebtest/integration/navigation/EnforceNavigateTo.scala new file mode 100755 index 0000000..ee9fc21 --- /dev/null +++ b/integration_test/src/it/scala/org/scalawebtest/integration/navigation/EnforceNavigateTo.scala @@ -0,0 +1,23 @@ +package org.scalawebtest.integration.navigation + +import org.scalatest.time.SpanSugar._ +import org.scalawebtest.integration.ScalaWebTestBaseSpec + +class EnforceNavigateTo extends ScalaWebTestBaseSpec{ + path = "/simpleAjax.jsp" + config.enableJavaScript(throwOnError = true) + config.enforceNavigateTo() + + "A simple webpage loading content with JS" should "be correctly interpreted by HtmlUnit" in { + eventually(timeout(1 second)) { + container.text should include("Text loaded with JavaScript") + } + } + it should "not be immediately available, if page was reloaded" in { + container.text should not include "Text loaded with JavaScript" + } + + def container = { + find(cssSelector("div#container")).get + } +}