I'm trying to use FluentLenium in Play with Scala to test our web form authentication. But it seems that the browser instance is not preserving state (or even loading) once the authentication form has been submitted... so, we submit the username and password, but it seems that the browser is not actually authentication. I'm guessing it has something to do with the browser state...?
I noticed there are some @SharedDriver settings documented, but these don't seem to work with our Scala test cases (they generate compiler errors).
The tests look like this:
class TestWebsiteAuthentication extends Specification {
val loginURL = routes.Application.login().url
val administrativePortalURL = routes.Application.index().url
var cookies: Set[Cookie]
"Application" should {
"login as an administrative user on the web site" in new WithBrowser with GPAuthenticationTestUtility {
browser.goTo(loginURL)
browser.fill("#email").`with`(prerequisiteAccounts.head.userIdentity)
browser.fill("#password").`with`(prerequisiteAccounts.head.password)
browser.submit("#submit")
browser.await().atMost(5, TimeUnit.SECONDS).untilPage().isLoaded
assert(browser.title().contains("Upload")) // FAILS HERE
}
/**
* This test will attempt to go to the upload page (after logging in, see previous test), and assert that the page has
* loaded (we assume that means access is granted).
*/
"go to the upload page after logging in" in new WithBrowser with GPAuthenticationTestUtility {
browser.goTo(administrativePortalURL)
browser.await().atMost(5, TimeUnit.SECONDS).untilPage().isLoaded
Logger.info("page title after login to admin page: " + browser.title()) // PRINTS THE HOME PAGE (NOT AUTHENTICATED PAGE)...?
assert(browser.title().contains("Upload")) // FAILS HERE
}
Any ideas what I'm doing wrong?