Explorar el Código

Starting to assert deeper into customer page

Andy Marks hace 9 años
padre
commit
078a7ae68c

+ 6
- 1
src/test/java/se/citerus/dddsample/acceptance/CustomerAcceptanceTest.java Ver fichero

@@ -1,6 +1,7 @@
1 1
 package se.citerus.dddsample.acceptance;
2 2
 
3 3
 import org.junit.Test;
4
+import se.citerus.dddsample.acceptance.pages.CustomerPage;
4 5
 import se.citerus.dddsample.acceptance.pages.LaunchPage;
5 6
 
6 7
 public class CustomerAcceptanceTest extends AbstractAcceptanceTest {
@@ -8,7 +9,11 @@ public class CustomerAcceptanceTest extends AbstractAcceptanceTest {
8 9
     public void customerSiteIsOperational() {
9 10
         LaunchPage home = new LaunchPage(driver,"http://localhost:8080/");
10 11
 
11
-        home.goToCustomerPage();
12
+        CustomerPage customerPage = home.goToCustomerPage();
13
+        customerPage.trackCargoWithIdOf("ABC123");
14
+        customerPage.expectCargoLocation("New York");
15
+
16
+
12 17
     }
13 18
 
14 19
 }

+ 18
- 0
src/test/java/se/citerus/dddsample/acceptance/pages/CustomerPage.java Ver fichero

@@ -1,11 +1,29 @@
1 1
 package se.citerus.dddsample.acceptance.pages;
2 2
 
3
+import org.openqa.selenium.By;
3 4
 import org.openqa.selenium.WebDriver;
5
+import org.openqa.selenium.WebElement;
4 6
 
5 7
 import static org.junit.Assert.assertEquals;
8
+import static org.junit.Assert.assertTrue;
6 9
 
7 10
 public class CustomerPage {
11
+    private final WebDriver driver;
12
+
8 13
     public CustomerPage(WebDriver driver) {
14
+        this.driver = driver;
9 15
         assertEquals("Tracking cargo", driver.getTitle());
10 16
     }
17
+
18
+    public void trackCargoWithIdOf(String trackingId) {
19
+        WebElement element = driver.findElement(By.id("idInput"));
20
+        element.sendKeys(trackingId);
21
+        element.submit();
22
+
23
+    }
24
+
25
+    public void expectCargoLocation(String expectedLocation) {
26
+        WebElement cargoSummary = driver.findElement(By.cssSelector("#result h2"));
27
+        assertTrue(cargoSummary.getText().endsWith(expectedLocation));
28
+    }
11 29
 }