Selenium WebDriver and Play
March 14, 2014 Leave a comment

I have advocated tests using Selenium WebDriver in the past many times. Will it become a de facto standard now that frameworks like Play make it very easy ?
It is not even evident below that Selenium WebDriver is being used. It is HTMLUNIT that is imported statically.
A test server is started, a test application is setup and a browser is simulated, all in a few lines of code. Very economical.
import static org.fest.assertions.Assertions.assertThat;
import static play.test.Helpers.*;
import org.junit.Test;
import controllers.routes;
import play.Logger;
import play.libs.F.Callback;
import play.test.TestBrowser;
import static helpers.TestSetup.*;
public class ProposalSubmissionTest {
@Test
public void proposalTest(){
running(testServer(3333,fakeApplication(testDbSettings())),HTMLUNIT, new Callback<TestBrowser>(){
@Override
public void invoke(TestBrowser browser) throws Throwable {
browser.goTo("http://localhost:3333" + routes.MainController.newProposal().url());
assertThat(browser.title()).isEqualTo("New Proposal");
Logger.debug(browser.title());
}
});
}
}