source: trunk/src/templates/artifacts/WebTest.groovy @ 896

Last change on this file since 896 was 128, checked in by gav, 16 years ago

Installed templates with grails install-templates

File size: 2.0 KB
Line 
1class @webtest.name.caps@Test extends grails.util.WebTest {
2
3    // Unlike unit tests, functional tests are often sequence dependent.
4    // Specify that sequence here.
5    void suite() {
6        test@webtest.name.caps@ListNewDelete()
7        // add tests for more operations here
8    }
9
10    def test@webtest.name.caps@ListNewDelete() {
11        webtest('@webtest.name.caps@ basic operations: view list, create new entry, view, edit, delete, view') {
12            invoke(url:'@webtest.name.lower@')
13            verifyText(text:'Home')
14
15            verifyListPage(0)
16
17            clickLink(label:'New @webtest.name.caps@')
18            verifyText(text:'Create @webtest.name.caps@')
19            clickButton(label:'Create')
20            verifyText(text:'Show @webtest.name.caps@', description:'Detail page')
21            clickLink(label:'List', description:'Back to list view')
22
23            verifyListPage(1)
24
25            group(description:'edit the one element') {
26                clickLink(label:'Show', description:'go to detail view')
27                clickButton(label:'Edit')
28                verifyText(text:'Edit @webtest.name.caps@')
29                clickButton(label:'Update')
30                verifyText(text:'Show @webtest.name.caps@')
31                clickLink(label:'List', description:'Back to list view')
32            }
33
34            verifyListPage(1)
35
36            group(description:'delete the only element') {
37                clickLink(label:'Show', description:'go to detail view')
38                clickButton(label:'Delete')
39                verifyXPath(xpath:"//div[@class='message']", text:/@webtest.name.caps@.*deleted./, regex:true)
40            }
41
42            verifyListPage(0)
43        }
44    }
45
46    String ROW_COUNT_XPATH = "count(//td[@class='actionButtons']/..)"
47
48    def verifyListPage(int count) {
49        ant.group(description:"verify @webtest.name.caps@ list view with $count row(s)") {
50            verifyText(text:'@webtest.name.caps@ List')
51            verifyXPath(xpath:ROW_COUNT_XPATH, text:count, description:"$count row(s) of data expected")
52        }
53    }
54}
Note: See TracBrowser for help on using the repository browser.