Rev | Line | |
---|
[929] | 1 | import geb.spock.GebReportingSpec |
---|
[948] | 2 | import gnumims.functional.pages.HomePage |
---|
| 3 | import gnumims.functional.pages.LoginPage |
---|
[929] | 4 | |
---|
| 5 | /** |
---|
[948] | 6 | * Provides a base class for functional testing. |
---|
| 7 | * Significantly speedup functional test development: |
---|
| 8 | * Run `grails test run-app`. |
---|
| 9 | * In a separate process run `grails interactive` |
---|
| 10 | * At the prompt `test-app functional: -baseUrl=http://localhost:8080/gnuMims -echoOut` |
---|
| 11 | * Hit enter to repeat tests very quickly. |
---|
[929] | 12 | */ |
---|
| 13 | class GebReportingSpecBase extends GebReportingSpec { |
---|
| 14 | def appName = grails.util.Metadata.current.'app.name' |
---|
| 15 | String getBaseUrl() { "http://localhost:8080/$appName/" } |
---|
| 16 | File getReportDir() { new File("target/test-reports/geb-pages") } |
---|
[948] | 17 | |
---|
| 18 | /** |
---|
| 19 | * Logs into the application either via a target page that requires |
---|
| 20 | * authentication or by directly requesting the login page. |
---|
| 21 | */ |
---|
[949] | 22 | void login(username, password, targetPage = null, params = [:]) { |
---|
[948] | 23 | if (targetPage) { |
---|
| 24 | to([*:params], targetPage) |
---|
| 25 | page LoginPage |
---|
| 26 | } |
---|
| 27 | else { |
---|
| 28 | to LoginPage |
---|
| 29 | } |
---|
| 30 | |
---|
| 31 | form.j_username = username |
---|
| 32 | form.j_password = password |
---|
| 33 | |
---|
| 34 | //if (targetPage) login.click(targetPage) |
---|
| 35 | if (targetPage) loginButton.click(HomePage) // gnuMims will always start at HomePage. |
---|
| 36 | else loginButton.click(HomePage) |
---|
| 37 | } |
---|
[952] | 38 | |
---|
| 39 | void logout() { |
---|
| 40 | if(logoutButton) |
---|
| 41 | logoutButton.click() |
---|
| 42 | } |
---|
| 43 | |
---|
[929] | 44 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.