here are the pom.xml customizations for using selenium server and client
4.0.0
com.spongeduke.tws.portal.webtests
com.spongeduke.tws.portal.webtests
jar
1.0-SNAPSHOT
com.spongeduke.tws.portal.webtests
http://maven.apache.org
1.0-beta-1
2.5.6
4.4
org.openqa.selenium.client-drivers
selenium-java-client-driver
${selenium.version}
test
org.springframework
spring
${spring.version}
test
junit
junit
${junit.version}
test
maven-compiler-plugin
1.5
org.codehaus.mojo
selenium-maven-plugin
xvfb
pre-integration-test
xvfb
:1
pre-integration-test
start-server
4447
true
org.apache.maven.plugins
maven-surefire-plugin
true
integration-test
test
false
openqa-releases
Openqa Release Repository
http://nexus.openqa.org/content/repositories/releases
default
false
true
openqa-snapshots
Openqa Snapshot Repository
http://nexus.openqa.org/content/repositories/snapshots
default
true
daily
ignore
false
and here's the sample unit test:
/**
* spongeduke (c) 2009
*/
package com.spongeduke.tws.portal.webtests;
import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.SeleneseTestCase;
import com.thoughtworks.selenium.Selenium;
/**
* Sample Selenium Test
*
* @author ctract2
*/
public class SampleSeleniumTest extends SeleneseTestCase {
private Selenium selenium;
public void setUp() {
selenium = new DefaultSelenium("localhost", 4447, "*firefox", "http://localhost:8080");
selenium.start();
}
public void testShouldShowWelcomePage() throws InterruptedException {
selenium.open("/portal");
selenium.waitForPageToLoad("5000");
verifyEquals("spongeduke DevPortal", selenium.getTitle());
verifyTrue(selenium.isTextPresent("spongeduke"));
}
public void tearDown() {
selenium.stop();
}
}
two ways of running the test:
1. using maven
$ mvn integration-test
2. using JUnit Runner in eclipse:
a. start Selenium Server: java -jar selenium-server.jar -port 4447
b. run Selenium Unit Test in eclipse using JUnit Runner
required selenium distribution: selenium-remote-control-1.0-beta-2-dist.zip
and can be downloaded from http://seleniumhq.org/download/
that's all folks!
No comments:
Post a Comment