Wednesday, October 8, 2008

my first Selenese test case!

i managed to squeeze some time to check out web automation testing using google's Selenium package.

here's the sample code:

/**
* JSF-Spring Integration Training
* Copyright MyCompany 2008
*/
package com.training;

import junit.framework.TestCase;
import com.thoughtworks.selenium.DefaultSelenium;

/**
* A Simple Unit Test using Selenium
*
* @author kits
*/
public class SimplePageTest extends TestCase {

protected DefaultSelenium createSeleniumClient(String url) throws Exception {
return new DefaultSelenium("localhost", 4444, "*firefox", url);
}

public void testSomethingSimple() throws Exception {
String url = "http://localhost:8010/clocator/faces/pages/index.jsp";
DefaultSelenium selenium = createSeleniumClient(url);

selenium.start();

selenium.isTextPresent("Hello JSF!!!");

selenium.stop();
}
}


and here's the dependency in my project's pom.xml:



and some plug-in configuration:



that's all there is to it... no sweat! =P

No comments: