Doing driven mode Selenium test with Java

Download Selenium Remote Control, unpack it.

Inside there is a Selenium server, and many client driver for different language.

Start the server by running java -jar selenium-server.jar. The default port is 4444.

Then open a java project in netbeans, include the client driver for java in your project, selenium-java-client-driver.jar .

Create DefaultSelenium object, this object will communicate with the server to run tests and do different tasks.

The constructor of DefaultSelenium need four parameters: hostname, port, browser string, url.

Browser string define what browser you use, please reference to the javadoc.

Here is a sample: new DefaultSelenium("localhost",4444,"*iexplore","http://www.google.com");

Run start() method to begin, stop() to close browser.

You may then integrate it with JUnit or TestNG to do data-driven tests.

According to their tutorial, TestNG should be easier.

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s