Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add "currentPage fits <html></html>" #83
- add CurrentPage class to IntegrationSpec - CurrentPage provides convenience methods to access webDriver.getPageSource, and HtmlGauge .fits, .fit, .doesntFit and not fit (via doesNotFit)
- Loading branch information
Showing
5 changed files
with
100 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...ration/src/it/scala/org/scalawebtest/integration/gauge/HtmlGaugeFromCurrentPageSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright 2016 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 the "License"; | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.scalawebtest.integration.gauge | ||
|
||
import org.scalawebtest.core.IntegrationFlatSpec | ||
import org.scalawebtest.core.gauge.HtmlGauge._ | ||
|
||
class HtmlGaugeFromCurrentPageSpec extends IntegrationFlatSpec { | ||
config.useBaseUri("http://localhost:9090") | ||
|
||
path = "/index.jsp" | ||
|
||
"CurrentPage" should "fit a matching GaugeDefinition" in { | ||
currentPage fits <h1>ScalaWebTest - Mock Server</h1> | ||
} | ||
it should "also work with fit (synonym of fits)" in { | ||
currentPage fit <h1>ScalaWebTest - Mock Server</h1> | ||
} | ||
it should "not fit a GaugeDefinition with a wrong title" in { | ||
currentPage doesntFit <h2>ScalaWebTest - False Text and Tag</h2> | ||
} | ||
it should """also work with "doesNotFit" (synonym of doesntFit)""" in { | ||
currentPage doesNotFit <h2>ScalaWebTest - False Text and Tag</h2> | ||
} | ||
} |
11 changes: 3 additions & 8 deletions
11
...test-integration/src/it/scala/org/scalawebtest/integration/response/CurrentPageSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,11 @@ | ||
package org.scalawebtest.integration.response | ||
|
||
import com.gargoylesoftware.htmlunit.html.HtmlPage | ||
import org.scalawebtest.core.ResponseAccessors | ||
import org.scalawebtest.integration.ScalaWebTestBaseSpec | ||
|
||
class CurrentPageSpec extends ScalaWebTestBaseSpec with ResponseAccessors { | ||
class CurrentPageSpec extends ScalaWebTestBaseSpec { | ||
path = "/index.jsp" | ||
|
||
"When opening a HTML page, it" should "be accessible via currentHtmlPage" in { | ||
currentHtmlPage.get shouldBe a[HtmlPage] | ||
} | ||
it should "return None when trying to get the currentXmlPage" in { | ||
currentXmlPage shouldBe None | ||
"CurrentPage.source" should "return the same as webdriver.getPageSource" in { | ||
currentPage.source shouldBe webDriver.getPageSource | ||
} | ||
} |