瀏覽代碼

Now have a simple Selenium test running from IDE only

Andy Marks 9 年之前
父節點
當前提交
63dd5d5573
共有 2 個文件被更改,包括 58 次插入0 次删除
  1. 6
    0
      pom.xml
  2. 52
    0
      src/test/acceptance/java/se/citerus/dddsample/AcceptanceTests.java

+ 6
- 0
pom.xml 查看文件

@@ -141,6 +141,12 @@
141 141
       <scope>test</scope>
142 142
     </dependency>
143 143
     <dependency>
144
+      <groupId>org.seleniumhq.selenium</groupId>
145
+      <artifactId>selenium-server</artifactId>
146
+      <version>3.4.0</version>
147
+      <scope>test</scope>
148
+    </dependency>
149
+    <dependency>
144 150
       <groupId>org.springframework</groupId>
145 151
       <artifactId>spring-webmvc</artifactId>
146 152
       <version>${spring.version}</version>

+ 52
- 0
src/test/acceptance/java/se/citerus/dddsample/AcceptanceTests.java 查看文件

@@ -0,0 +1,52 @@
1
+package se.citerus.dddsample;
2
+
3
+import org.junit.After;
4
+import org.junit.Before;
5
+import org.junit.Test;
6
+import org.openqa.selenium.By;
7
+import org.openqa.selenium.WebDriver;
8
+import org.openqa.selenium.WebElement;
9
+import org.openqa.selenium.chrome.ChromeDriver;
10
+
11
+import static org.junit.Assert.assertEquals;
12
+
13
+public class AcceptanceTests {
14
+    private WebDriver driver;
15
+
16
+    @Before
17
+    public void setup() {
18
+        driver = new ChromeDriver();
19
+    }
20
+
21
+    @Test
22
+    public void customerSiteIsOperational() {
23
+        driver.get("http://localhost:8080/dddsample");
24
+
25
+        assertEquals("DDDSample", driver.getTitle());
26
+        WebElement adminLink = driver.findElement(By.linkText("cargo tracking"));
27
+        adminLink.click();
28
+
29
+        assertEquals("Tracking cargo", driver.getTitle());
30
+//
31
+//        WebElement trackingIdInput = driver.findElement(By.id("idInput"));
32
+//        trackingIdInput.submit();
33
+
34
+    }
35
+
36
+    @Test
37
+    public void adminSiteIsOperational() {
38
+        driver.get("http://localhost:8080/dddsample");
39
+
40
+        assertEquals("DDDSample", driver.getTitle());
41
+        WebElement adminLink = driver.findElement(By.linkText("booking and routing"));
42
+        adminLink.click();
43
+
44
+        assertEquals("Cargo Administration", driver.getTitle());
45
+    }
46
+
47
+    @After
48
+    public void tearDown() {
49
+        driver.quit();
50
+
51
+    }
52
+}