Permalink
Browse files

moved selenium tests to their own packages

  • Loading branch information...
1 parent 171878e commit 4a281280f1bd5613f9d7f38165e653869d72b385 @jesseeichar jesseeichar committed Sep 27, 2011
@@ -1,7 +1,7 @@
package c2c.webspecs
package geonetwork
package geocat
-package spec.WP10
+package spec.WP10.selenium
import org.specs2._
import matcher.ThrownExpectations
@@ -2,7 +2,7 @@ package c2c.webspecs
package geonetwork
package geocat
package spec
-package WP10
+package WP10.selenium
import org.specs2._
import matcher.ThrownExpectations
@@ -2,7 +2,7 @@ package c2c.webspecs
package geonetwork
package geocat
package spec
-package WP16
+package WP16.selenium
import org.specs2._
import matcher.ThrownExpectations
@@ -15,11 +15,8 @@ class SearchOrderSpec extends GeocatSpecification { def is =
"Title search order".title ^
"Test the search order by title" ^ Step(setup) ^
"Import several metadata with interesting titles and languages" ^ Step(importMd) ^
- "Do a normal search to get the baseline search" ^ Step(baselineSearch) ^
"Sort by title in french and verify all MD are correctly sorted" ! frTitleSearch ^
"Sort by title in english and verify all MD are correctly sorted" ! enTitleSearch ^
- "Sort by date in french and verify all MD are correctly sorted" ! frDateSearch ^
- "Sort by date in english and verify all MD are correctly sorted" ! frDateSearch ^
Step(tearDown)
val timeStamp = System.currentTimeMillis()
@@ -33,76 +30,52 @@ class SearchOrderSpec extends GeocatSpecification { def is =
doImport("eng", <gmd:PT_FreeText>
<gmd:textGroup><gmd:LocalisedCharacterString locale="#DE">zz</gmd:LocalisedCharacterString></gmd:textGroup>
</gmd:PT_FreeText>)
- doImport("fra", <gmd:PT_FreeText>
- <gmd:textGroup><gmd:LocalisedCharacterString locale="#FR">A FRA EN and FR is FR</gmd:LocalisedCharacterString></gmd:textGroup>
- <gmd:textGroup><gmd:LocalisedCharacterString locale="#EN">A FRA EN and FR is EN</gmd:LocalisedCharacterString></gmd:textGroup>
- </gmd:PT_FreeText>)
doImport("eng", <gmd:PT_FreeText>
<gmd:textGroup><gmd:LocalisedCharacterString locale="#FR">A ENG EN and FR is FR</gmd:LocalisedCharacterString></gmd:textGroup>
<gmd:textGroup><gmd:LocalisedCharacterString locale="#EN">A ENG EN and FR is EN</gmd:LocalisedCharacterString></gmd:textGroup>
</gmd:PT_FreeText>)
doImport("eng", <gmd:PT_FreeText>
+ <gmd:textGroup><gmd:LocalisedCharacterString locale="#FR">G eng is fr</gmd:LocalisedCharacterString></gmd:textGroup>
+ </gmd:PT_FreeText>)
+ doImport("eng", <gmd:PT_FreeText>
<gmd:textGroup><gmd:LocalisedCharacterString locale="#FR">b eng en and fr is fr</gmd:LocalisedCharacterString></gmd:textGroup>
<gmd:textGroup><gmd:LocalisedCharacterString locale="#EN">b eng en and fr is en</gmd:LocalisedCharacterString></gmd:textGroup>
</gmd:PT_FreeText>)
doImport("fra", <gmd:PT_FreeText>
<gmd:textGroup><gmd:LocalisedCharacterString locale="#FR">b fra is fr</gmd:LocalisedCharacterString></gmd:textGroup>
</gmd:PT_FreeText>)
- doImport("eng", <gmd:PT_FreeText>
- <gmd:textGroup><gmd:LocalisedCharacterString locale="#FR">G eng is fr</gmd:LocalisedCharacterString></gmd:textGroup>
+ doImport("fra", <gmd:PT_FreeText>
+ <gmd:textGroup><gmd:LocalisedCharacterString locale="#FR">A FRA EN and FR is FR</gmd:LocalisedCharacterString></gmd:textGroup>
+ <gmd:textGroup><gmd:LocalisedCharacterString locale="#EN">A FRA EN and FR is EN</gmd:LocalisedCharacterString></gmd:textGroup>
</gmd:PT_FreeText>)
}
lazy val baselineSearch = {
- val cswResponse = CswGetRecordsRequest(PropertyIsEqualTo("abstract", timeStamp.toString).xml, ResultTypes.results, elementSetName = ElementSetNames.summary, outputSchema=OutputSchemas.Record)()
+ val cswResponse = CswGetRecordsRequest(PropertyIsEqualTo("abstract", timeStamp.toString).xml, ResultTypes.results, elementSetName = ElementSetNames.summary, outputSchema = OutputSchemas.Record)()
cswResponse.value.getXml \\ "SummaryRecord" \\ "title"
}
def frTitleSearch = {
val cswResponse = CswGetRecordsRequest(
- PropertyIsEqualTo("abstract", timeStamp.toString).xml,
- ResultTypes.results,
- outputSchema=OutputSchemas.Record,
- elementSetName = ElementSetNames.summary,
- url = "fra/csw",
- sortBy = List(SortBy("_defaultTitle", true)))()
+ PropertyIsEqualTo("abstract", timeStamp.toString).xml,
+ ResultTypes.results,
+ outputSchema = OutputSchemas.Record,
+ elementSetName = ElementSetNames.summary,
+ url = "fra/csw",
+ sortBy = List(SortBy("_defaultTitle", true)))()
val records = cswResponse.value.getXml \\ "SummaryRecord" \\ "title" map (_.text)
- records must haveTheSameElementsAs(List("A FRA EN and FR is FR", "b fra is fr", "A ENG EN and FR is FR", "b eng en and fr is fr", "G eng is fr","zz"))
+ records must contain("A FRA EN and FR is FR", "b fra is fr", "A ENG EN and FR is FR", "b eng en and fr is fr", "G eng is fr", "zz").only.inOrder
}
def enTitleSearch = {
val cswResponse = CswGetRecordsRequest(
- PropertyIsEqualTo("abstract", timeStamp.toString).xml,
- ResultTypes.results,
- elementSetName = ElementSetNames.summary,
- url = "eng/csw",
- outputSchema=OutputSchemas.Record,
- sortBy = List(SortBy("_defaultTitle", true)))()
+ PropertyIsEqualTo("abstract", timeStamp.toString).xml,
+ ResultTypes.results,
+ elementSetName = ElementSetNames.summary,
+ url = "eng/csw",
+ outputSchema = OutputSchemas.Record,
+ sortBy = List(SortBy("_defaultTitle", true)))()
val records = cswResponse.value.getXml \\ "SummaryRecord" \\ "title" map (_.text)
- records must haveTheSameElementsAs(List("A ENG EN and FR is EN", "b eng en and fr is en", "G eng is fr", "zz", "A FRA EN and FR is EN", "b fra is fr"))
+ records must contain("A ENG EN and FR is EN", "b eng en and fr is en", "G eng is fr", "zz", "A FRA EN and FR is EN", "b fra is fr").only.inOrder
}
-def frDateSearch = {
- val cswResponse = CswGetRecordsRequest(
- PropertyIsEqualTo("abstract", timeStamp.toString).xml,
- ResultTypes.results,
- outputSchema=OutputSchemas.Record,
- elementSetName = ElementSetNames.summary,
- url = "fra/csw",
- sortBy = List(SortBy("changeDate", true)))()
- val records = cswResponse.value.getXml \\ "SummaryRecord" \\ "title" map (_.text)
-
- records must haveTheSameElementsAs(List("A FRA EN and FR is FR", "b fra is fr", "A ENG EN and FR is FR", "b eng en and fr is fr", "G eng is fr","zz"))
-}
-def enDateSearch = {
- val cswResponse = CswGetRecordsRequest(
- PropertyIsEqualTo("abstract", timeStamp.toString).xml,
- ResultTypes.results,
- elementSetName = ElementSetNames.summary,
- url = "eng/csw",
- outputSchema=OutputSchemas.Record,
- sortBy = List(SortBy("changeDate", true)))()
- val records = cswResponse.value.getXml \\ "SummaryRecord" \\ "title" map (_.text)
-
- records must haveTheSameElementsAs(List("A ENG EN and FR is EN", "b eng en and fr is en", "G eng is fr", "zz", "A FRA EN and FR is EN", "b fra is fr"))
-}
}
@@ -2,7 +2,7 @@ package c2c.webspecs
package geonetwork
package geocat
package spec
-package WP7
+package WP7.selenium
import csw._
import org.specs2._
@@ -2,7 +2,7 @@ package c2c.webspecs
package geonetwork
package geocat
package spec
-package WP7
+package WP7.selenium
import org.specs2._
import matcher.ThrownExpectations
@@ -0,0 +1,105 @@
+package c2c.webspecs
+package geonetwork
+package geocat
+package spec
+package WP7.selenium
+
+import org.specs2._
+import matcher.ThrownExpectations
+import specification.Step
+import Thread._
+import org.openqa.selenium.WebDriverBackedSelenium
+import org.junit.runner.RunWith
+import org.specs2.runner.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+class SearchesReturnResultsSeleniumSpec extends GeocatSeleniumSpecification with ThrownExpectations {
+ override lazy val selenium = new WebDriverBackedSelenium(driver, "http://" + Properties.testServer)
+
+ def isImpl =
+ "This specification tests SearchesReturnResultsSeleniumSpec" ^
+ "This spec runs several searches then modifies the ordering and verifies that a result still completes."! scala_specs2_1^
+ "sortBy date and ensure that results are correctly displayed" ! scala_specs2_2^
+ "sortBy populatiry and ensure that results are correctly displayed" ! scala_specs2_3^
+ "sortBy rating and ensure that results are correctly displayed" ! scala_specs2_4^
+ "sortBy relevance and ensure that results are correctly displayed" ! scala_specs2_5^
+ "sortBy title and ensure that results are correctly displayed" ! scala_specs2_6
+
+ def scala_specs2_1 = {
+ import selenium._
+ open("/geonetwork/srv/eng/geocat")
+ `type`("id=username", "admin")
+ `type`("id=password", "Hup9ieBe")
+ click("id=loginButton")
+ waitForPageToLoad("30000")
+ success
+ }
+
+ def scala_specs2_2 = {
+ import selenium._
+ click("id=ext-gen53")
+ doWait(isElementPresent("//div[@id='sortBy']//img"))
+ click("//div[@id='sortBy']//img")
+ click("css=div.x-combo-list-item")
+ doWait(isElementPresent("//div[@id='records']/table/tbody/tr/td[2]"))
+ (isElementPresent("//div[@id='records']/table/tbody/tr/td[2]") must beTrue) and
+ ("Change date" must beEqualTo(getValue("id=sortByCombo")).ignoreCase)
+ }
+
+ def scala_specs2_3 = {
+ import selenium._
+ refresh()
+ waitForPageToLoad("30000")
+ click("id=ext-gen53")
+ doWait(isElementPresent("//div[@id='sortBy']//img"))
+ click("//div[@id='sortBy']//img")
+ click("css=div.x-combo-list-item + div")
+ doWait(isElementPresent("//div[@id='records']/table/tbody/tr/td[2]"))
+ (isElementPresent("//div[@id='records']/table/tbody/tr/td[2]") must beTrue) and
+ ("Popularity" must beEqualTo(getValue("id=sortByCombo")).ignoreCase)
+ }
+
+ def scala_specs2_4 = {
+ import selenium._
+ refresh()
+ waitForPageToLoad("30000")
+ click("id=ext-gen53")
+ doWait(isElementPresent("//div[@id='sortBy']//img"))
+ click("//div[@id='sortBy']//img")
+ click("css=div.x-combo-list-item + div + div")
+ doWait(isElementPresent("//div[@id='records']/table/tbody/tr/td[2]"))
+ (isElementPresent("//div[@id='records']/table/tbody/tr/td[2]") must beTrue) and
+ ("Rating" must beEqualTo(getValue("id=sortByCombo")).ignoreCase)
+ }
+
+ def scala_specs2_5 = {
+ import selenium._
+ refresh()
+ waitForPageToLoad("30000")
+ click("id=ext-gen53")
+ doWait(isElementPresent("//div[@id='sortBy']//img"))
+ click("//div[@id='sortBy']//img")
+ click("css=div.x-combo-list-item + div + div + div")
+ doWait(isElementPresent("//div[@id='records']/table/tbody/tr/td[2]"))
+ (isElementPresent("//div[@id='records']/table/tbody/tr/td[2]") must beTrue) and
+ ("Relevance" must beEqualTo(getValue("id=sortByCombo")).ignoreCase)
+ }
+
+ def scala_specs2_6 = {
+ import selenium._
+ refresh()
+ waitForPageToLoad("30000")
+ click("id=ext-gen53")
+ doWait(isElementPresent("//div[@id='sortBy']//img"))
+ click("//div[@id='sortBy']//img")
+ click("css=div.x-combo-list-item + div + div + div + div")
+ doWait(isElementPresent("//div[@id='records']/table/tbody/tr/td[2]"))
+ (isElementPresent("//div[@id='records']/table/tbody/tr/td[2]") must beTrue) and
+ ("Title" must beEqualTo(getValue("id=sortByCombo")).ignoreCase)
+ }
+
+ val TIMEOUT = 30
+ private def doWait(assertion: => Boolean, waits:Int=TIMEOUT, length:Int=1000) =
+ (1 to waits).view map {_=> sleep(length)} find { _ => assertion }
+
+}
Oops, something went wrong.

0 comments on commit 4a28128

Please sign in to comment.