Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added new tests

  • Loading branch information...
commit ba9dd4dac5160ed2e8894c6b201bad11c5521b6a 1 parent 39c96bf
John Ferguson Smart authored December 25, 2011
49  ...ides-showcase-simple-webtests/src/main/java/net/thucydides/showcase/simple/pages/AdvancedSearchPage.java
... ...
@@ -0,0 +1,49 @@
  1
+package net.thucydides.showcase.simple.pages;
  2
+
  3
+import net.thucydides.core.annotations.DefaultUrl;
  4
+import net.thucydides.core.pages.PageObject;
  5
+import org.openqa.selenium.WebDriver;
  6
+import org.openqa.selenium.WebElement;
  7
+import org.openqa.selenium.support.FindBy;
  8
+
  9
+@DefaultUrl("http://search.maven.org/")
  10
+public class AdvancedSearchPage extends PageObject {
  11
+
  12
+    private WebElement groupId;
  13
+    private WebElement artifactId;
  14
+    private String value;
  15
+    private WebElement version;
  16
+    private WebElement packaging;
  17
+    private WebElement classifier;
  18
+
  19
+    private WebElement gavSearchButton;
  20
+
  21
+    public AdvancedSearchPage(WebDriver driver) {
  22
+        super(driver);
  23
+    }
  24
+
  25
+    public void setGroupId(String value) {
  26
+        element(groupId).type(value);
  27
+    }
  28
+
  29
+    public void setArtifactId(String value) {
  30
+        element(artifactId).type(value);
  31
+    }
  32
+
  33
+    public void setVersion(String value) {
  34
+        element(version).type(value);
  35
+    }
  36
+
  37
+    public void setPackaging(String value) {
  38
+        element(packaging).type(value);
  39
+    }
  40
+
  41
+    public void setClassifier(String value) {
  42
+        element(classifier).type(value);
  43
+    }
  44
+
  45
+
  46
+    public void startSearch() {
  47
+        element(gavSearchButton).click();
  48
+    }
  49
+}
53  ...imple-webtests/src/test/java/net/thucydides/showcase/simple/WhenSearchingForArtifactsUsingAWildCard.java
... ...
@@ -0,0 +1,53 @@
  1
+package net.thucydides.showcase.simple;
  2
+
  3
+import net.thucydides.core.annotations.Managed;
  4
+import net.thucydides.core.annotations.ManagedPages;
  5
+import net.thucydides.core.annotations.Steps;
  6
+import net.thucydides.core.annotations.Story;
  7
+import net.thucydides.core.pages.Pages;
  8
+import net.thucydides.junit.runners.ThucydidesRunner;
  9
+import net.thucydides.showcase.simple.requirements.Application;
  10
+import net.thucydides.showcase.simple.steps.DeveloperSteps;
  11
+import org.junit.Test;
  12
+import org.junit.runner.RunWith;
  13
+import org.openqa.selenium.WebDriver;
  14
+
  15
+import static net.thucydides.core.matchers.BeanMatchers.each;
  16
+import static net.thucydides.core.matchers.BeanMatchers.the;
  17
+import static net.thucydides.core.matchers.BeanMatchers.the_count;
  18
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
  19
+import static org.hamcrest.Matchers.is;
  20
+import static org.hamcrest.Matchers.startsWith;
  21
+
  22
+@RunWith(ThucydidesRunner.class)
  23
+@Story(Application.Search.SearchForArtifactsByName.class)
  24
+public class WhenSearchingForArtifactsUsingAWildCard {
  25
+
  26
+    @Managed
  27
+    WebDriver driver;
  28
+
  29
+    @ManagedPages(defaultUrl = "http://search.maven.org")
  30
+    public Pages pages;
  31
+
  32
+    @Steps
  33
+    public DeveloperSteps developer;
  34
+
  35
+    @Test
  36
+    public void should_search_for_artifacts_by_name_containing_a_wildcard() {
  37
+        developer.opens_the_search_page();
  38
+        developer.searches_for("thucydides*");
  39
+        developer.should_see_artifacts_where(the("ArtifactId", is("thucydides")),
  40
+                                             the("GroupId", is("net.thucydides")));
  41
+
  42
+    }
  43
+
  44
+    @Test
  45
+    public void should_find_the_right_number_of_artifacts_when_using_a_wildcard() {
  46
+        developer.opens_the_search_page();
  47
+        developer.searches_for("thucydides*");
  48
+        developer.should_see_artifacts_where(the("GroupId", startsWith("net.thucydides")),
  49
+                each("ArtifactId").isDifferent(),
  50
+                the_count(is(greaterThanOrEqualTo(16))));
  51
+
  52
+    }
  53
+}
44  ...va/net/thucydides/showcase/simple/WhenSearchingForArtifactsUsingMultipleCriteriaInTheAdvancedSearch.java
... ...
@@ -0,0 +1,44 @@
  1
+package net.thucydides.showcase.simple;
  2
+
  3
+import net.thucydides.core.annotations.Managed;
  4
+import net.thucydides.core.annotations.ManagedPages;
  5
+import net.thucydides.core.annotations.Steps;
  6
+import net.thucydides.core.annotations.Story;
  7
+import net.thucydides.core.pages.Pages;
  8
+import net.thucydides.junit.runners.ThucydidesRunner;
  9
+import net.thucydides.showcase.simple.requirements.Application;
  10
+import net.thucydides.showcase.simple.steps.DeveloperSteps;
  11
+import org.junit.Test;
  12
+import org.junit.runner.RunWith;
  13
+import org.openqa.selenium.WebDriver;
  14
+
  15
+import static net.thucydides.core.matchers.BeanMatchers.each;
  16
+import static net.thucydides.core.matchers.BeanMatchers.the;
  17
+import static net.thucydides.core.matchers.BeanMatchers.the_count;
  18
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
  19
+import static org.hamcrest.Matchers.is;
  20
+import static org.hamcrest.Matchers.startsWith;
  21
+
  22
+@RunWith(ThucydidesRunner.class)
  23
+@Story(Application.Search.SearchForArtifactsByName.class)
  24
+public class WhenSearchingForArtifactsUsingMultipleCriteriaInTheAdvancedSearch {
  25
+
  26
+    @Managed
  27
+    WebDriver driver;
  28
+
  29
+    @ManagedPages(defaultUrl = "http://search.maven.org")
  30
+    public Pages pages;
  31
+
  32
+    @Steps
  33
+    public DeveloperSteps developer;
  34
+
  35
+    @Test
  36
+    public void should_search_for_artifacts_by_group_id_and_version() {
  37
+        developer.opens_the_advanced_search_page();
  38
+        developer.searches_by_group_and_version("net.thucydides","0.6.0");
  39
+        developer.should_see_artifacts_where(the("GroupId", is("net.thucydides")),
  40
+                                             the("Version", is("0.6.0")));
  41
+
  42
+    }
  43
+
  44
+}
53  ...btests/src/test/java/net/thucydides/showcase/simple/WhenSearchingForArtifactsUsingTheAdvancedSearch.java
... ...
@@ -0,0 +1,53 @@
  1
+package net.thucydides.showcase.simple;
  2
+
  3
+import net.thucydides.core.annotations.Managed;
  4
+import net.thucydides.core.annotations.ManagedPages;
  5
+import net.thucydides.core.annotations.Steps;
  6
+import net.thucydides.core.annotations.Story;
  7
+import net.thucydides.core.pages.Pages;
  8
+import net.thucydides.junit.runners.ThucydidesRunner;
  9
+import net.thucydides.showcase.simple.requirements.Application;
  10
+import net.thucydides.showcase.simple.steps.DeveloperSteps;
  11
+import org.junit.Test;
  12
+import org.junit.runner.RunWith;
  13
+import org.openqa.selenium.WebDriver;
  14
+
  15
+import static net.thucydides.core.matchers.BeanMatchers.each;
  16
+import static net.thucydides.core.matchers.BeanMatchers.the;
  17
+import static net.thucydides.core.matchers.BeanMatchers.the_count;
  18
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
  19
+import static org.hamcrest.Matchers.is;
  20
+import static org.hamcrest.Matchers.startsWith;
  21
+
  22
+@RunWith(ThucydidesRunner.class)
  23
+@Story(Application.Search.SearchForArtifactsByName.class)
  24
+public class WhenSearchingForArtifactsUsingTheAdvancedSearch {
  25
+
  26
+    @Managed
  27
+    WebDriver driver;
  28
+
  29
+    @ManagedPages(defaultUrl = "http://search.maven.org")
  30
+    public Pages pages;
  31
+
  32
+    @Steps
  33
+    public DeveloperSteps developer;
  34
+
  35
+    @Test
  36
+    public void should_search_for_artifacts_by_group_id() {
  37
+        developer.opens_the_advanced_search_page();
  38
+        developer.searches_by_group("net.thucydides");
  39
+        developer.should_see_artifacts_where(the("GroupId", is("net.thucydides")),
  40
+                                             the_count(greaterThanOrEqualTo(10)));
  41
+
  42
+    }
  43
+
  44
+    @Test
  45
+    public void should_search_for_artifacts_by_artifact_id() {
  46
+        developer.opens_the_advanced_search_page();
  47
+        developer.searches_by_artifact("thucydides-core");
  48
+        developer.should_see_artifacts_where(the("ArtifactId", is("thucydides-core")), 
  49
+                                             the_count(is(1)));
  50
+
  51
+    }
  52
+
  53
+}

0 notes on commit ba9dd4d

Please sign in to comment.
Something went wrong with that request. Please try again.