Revision as of 01:58, 4 January 2015 by Mr lou d (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)

Selenium plugin

Selenium is a portable software testing framework for web applications. The tests can be written as HTML tables or coded in a number of popular programming languages and can be run directly in most modern web browsers. Selenium can be deployed on Windows, Linux, and Macintosh. For more details see the Selenium web site.

This page describes how to run Selenium tests in NetBeans.

  • download Selenium plugin from development update center
  • create new WebApplication or open your existing WebApplication
  • create new Selenium test case from Selenium category using new file wizard

After creating new Selenium test case new Selenium Test Packages are created and Selenium libraries are attached to your project. libraries, Selenium Test Packages screenshot

  • you can write Selenium test by hand, but it's easier and faster to use Selenium IDE and copy generated source into your project
  • run Selenium tests and unit tests separatelly using project popup menu item or main menu item in Run category

selenium, unit tests popup menu screenshot

  • run all your Selenium and unit tests using Test action
  • run just one Selenium test using Test file action in Run category of main menu

Selenium server management

Selenium server is registered in Servers section of Services tab

  • you can start, stop or restart it if needed using popup menu - note that Selenium tests won't run without running server
  • you can set server properties - note that's needed to restart NetBeans to aply selenium server properties changes (will be fixed later)

selenium server node

Switching selenium to non default port

  1. To set up different server port can be usefull for example while using JBoss Application Server, because it uses port 4444 for it's own services.
  2. Use Selenium server node in Servers section of Services tab to invoke selenium server properties.
  3. Set your preferred port and close the Properties window. Selenium server gets restarted immediatelly.
  4. Modify you tests to use correct port. Use this code sample - you can also modify your templates to generate new files correctly.

This sample setUp method could help you with such job. You can dirrectly paste it into Selenium java client test case template.

	public void setUp() throws Exception {
            String seleniumServerHost = "localhost";
            int seleniumServerPort = ${selenium_server_port};
            String testerURL = "http://localhost:${server_port}/";
            String browserString = "*firefox";
            selenium = new DefaultSelenium(seleniumServerHost, seleniumServerPort, browserString, testerURL);
            selenium.setContext(this.getClass().getSimpleName() + "." + getName());

You will also need to add one more import:

 import com.thoughtworks.selenium.DefaultSelenium 

If you need to use Selenium in Maven project see this page. If you need to use Selenium in PHP project see this page.

Another use case is to have a simple java aplication for Selenium functional tests and have no functional tests in web application. In such case just create java application and use Selenium TestCase in the same manner as in WebApplication. The execution is also the same as in Web Application - use Run Selenium Tests, Run Unit Tests or simply Test to run the suite. Note: You will probably have to close and reopen the java project to reload new configuration created by Selenium plugin after creating first Selenium TestCase.

}}small Jan/27/2009 }}

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo