Skip to main content

Posts

Showing posts from January, 2012

Page Object Pattern + WebDriver + Spring

During the last week I had start creating a test suite for a existing web-application which my team is currently working on. So now is good time to share some experience: The application A normal old java web application: Java 1.4, Struts 1.1, EJB 2.1, JDBC to persist the data and the anemic design (VO+BO+DAO) but I will talk about in another post... Page Object Pattern To map the web page's components inside the test code I used the page object pattern. This patterns helped me to eliminate duplicated code to access web-page's components. Basically it consists of classes that maps web-pages, so that if you want to fill a login form from your test classes instead of doing this: @Test public void someTest() throws Exception { WebElement userNameField = driver.findElement(By.name("j_username")); userNameField.sendKeys(username); WebElement passwordField = driver.findElement(By.name("j_password")); passwordField