1 | package test |
---|
2 | |
---|
3 | import org.specs2.mutable._ |
---|
4 | |
---|
5 | import play.api.test._ |
---|
6 | import play.api.test.Helpers._ |
---|
7 | |
---|
8 | import org.fluentlenium.core.filter.FilterConstructor._ |
---|
9 | |
---|
10 | class IntegrationSpec extends Specification { |
---|
11 | |
---|
12 | "Application" should { |
---|
13 | |
---|
14 | "work from within a browser" in { |
---|
15 | running(TestServer(3333), HTMLUNIT) { browser => |
---|
16 | browser.goTo("http://localhost:3333/") |
---|
17 | |
---|
18 | browser.$("header h1").first.getText must equalTo("Play 2.0 sample application â Computer database") |
---|
19 | browser.$("section h1").first.getText must equalTo("574 computers found") |
---|
20 | |
---|
21 | browser.$("#pagination li.current").first.getText must equalTo("Displaying 1 to 10 of 574") |
---|
22 | |
---|
23 | browser.$("#pagination li.next a").click() |
---|
24 | |
---|
25 | browser.$("#pagination li.current").first.getText must equalTo("Displaying 11 to 20 of 574") |
---|
26 | browser.$("#searchbox").text("Apple") |
---|
27 | browser.$("#searchsubmit").click() |
---|
28 | |
---|
29 | browser.$("section h1").first.getText must equalTo("13 computers found") |
---|
30 | browser.$("a", withText("Apple II")).click() |
---|
31 | |
---|
32 | browser.$("section h1").first.getText must equalTo("Edit computer") |
---|
33 | |
---|
34 | browser.$("#discontinued").text("xxx") |
---|
35 | browser.$("input.primary").click() |
---|
36 | |
---|
37 | browser.$("div.error").size must equalTo(1) |
---|
38 | browser.$("div.error label").first.getText must equalTo("Discontinued date") |
---|
39 | |
---|
40 | browser.$("#discontinued").text("") |
---|
41 | browser.$("input.primary").click() |
---|
42 | |
---|
43 | browser.$("section h1").first.getText must equalTo("574 computers found") |
---|
44 | browser.$(".alert-message").first.getText must equalTo("Done! Computer Apple II has been updated") |
---|
45 | |
---|
46 | browser.$("#searchbox").text("Apple") |
---|
47 | browser.$("#searchsubmit").click() |
---|
48 | |
---|
49 | browser.$("a", withText("Apple II")).click() |
---|
50 | browser.$("input.danger").click() |
---|
51 | |
---|
52 | browser.$("section h1").first.getText must equalTo("573 computers found") |
---|
53 | browser.$(".alert-message").first.getText must equalTo("Done! Computer has been deleted") |
---|
54 | |
---|
55 | browser.$("#searchbox").text("Apple") |
---|
56 | browser.$("#searchsubmit").click() |
---|
57 | |
---|
58 | browser.$("section h1").first.getText must equalTo("12 computers found") |
---|
59 | |
---|
60 | } |
---|
61 | } |
---|
62 | |
---|
63 | } |
---|
64 | |
---|
65 | } |
---|