Selenium Server

The simple test case below illustrates the usage of the Selenium 1.0 API. Please note that a Selenium Server must be running in order to execute this test case.

package com.btmatthews.selenium.junit4.runner.test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import org.junit.Test;
import org.junit.runner.RunWith;

import com.btmatthews.selenium.junit4.runner.SeleniumBrowser;
import com.btmatthews.selenium.junit4.runner.SeleniumJUnit4ClassRunner;
import com.btmatthews.selenium.junit4.runner.SeleniumServer;
import com.btmatthews.selenium.junit4.runner.ServerConfiguration;
import com.thoughtworks.selenium.Selenium;

/**
 * Unit tests for the {@link ServerConfiguration} configuration style.
 * 
 * @author <a href="mailto:brian@btmatthews.com">Brian Thomas Matthews</a>
 * @since 1.0.0
 */
@RunWith(SeleniumJUnit4ClassRunner.class)
@ServerConfiguration(browserURL = "http://www.google.com")
public final class TestServer {

        /**
         * The object used to start/stop the server used for testing.
         */
        @SeleniumServer
        private Selenium server;

    /**
     * The name of the browser being used for the test.
     */ 
        @SeleniumBrowser
        private String browserName;

        /**
         * Verify that the test runner injected the Selenium Server.
         */
        @Test
        public void testInjection() {
                assertNotNull(server);
                assertNotNull(browserName);
                assertEquals("firefox", browserName);
        }

        /**
         * Verify that we can navigate to the Google home page.
         */
        @Test
        public void testHomePage() {
                server.open("/");
                assertEquals("Google", server.getTitle());
        }
}