Selenium WebDriver and Play

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 {

	public void proposalTest(){
		running(testServer(3333,fakeApplication(testDbSettings())),HTMLUNIT, new Callback<TestBrowser>(){

			public void invoke(TestBrowser browser) throws Throwable {
				browser.goTo("http://localhost:3333" + routes.MainController.newProposal().url());
				assertThat(browser.title()).isEqualTo("New Proposal");

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: