Last updated by fletcherr 2 years ago
Extending GrailsSeleniumTestCase
Instead of using theSeleniumTest mixin you can extend grails.plugins.selenium.GrailsSeleniumTestCase which provides
everything the mixin does with some additional capabilities. Firstly you can use some of the more advanced assertions
provided by the SeleneseTestBase
class as well as the various verify methods, the seleniumEquals method, etc. See the documentation for SeleneseTestBase for
details.Using assert, verify and waitFor convenience methods
ExtendingGrailsSeleniumTestCase enables you to directly assert, verify or waitFor certain Selenium conditions. Any
Selenium
method starting with is can be used as a boolean assertion by replacing the is with assert, verify or waitFor in
the method call. Likewise any Selenium method starting with get can be used as an equality assertion. The following
table gives some examples:| Without GrailsSeleniumTestCase | With GrailsSeleniumTestCase |
|---|---|
| assertTrue selenium.isTextPresent("Welcome to Grails") | assertTextPresent("Welcome to Grails") |
| verifyTrue selenium.isVisible("myElement") | verifyVisible("myElement") |
| waitFor { selenium.isAlertPresent() } | waitForAlertPresent() |
| assertEquals("Expected text", selenium.getText("myElement")) | assertText("Expected text", "myElement") |
| waitFor { selenium.getXpathCount("//ul/li") == 3 } | waitForXpathCount 3, "//ul/li" |



