Posts Tagged ‘Testing Methods’

Print This Post This page as PDF Email This Post Working with Selenium-Grid and run PHP Tests

Monday, June 1st, 2009

By Vaishal,

Working with Selenium-Grid

1. Download selenium Grid from
http://seleniumhq.org/download/
And extract files any location. Mostly in C:\selenium

2. Install latest jre from

http://java.sun.com/

3. Download ant from

http://ant.apache.org/
Extract files in C:\Ant.

- Set environment variable ANT_HOME as
- Go to the properties menu of MyComputer
- Go to the advance menu and click on ‘Environment Variable’
- Click on new and Enter value ‘ANT_HOME’ variable with your folder value where you have installed Ant.
- Now set the path variable as
Edit value and add location of your ant\bin folder

4. Now go to the selenium-grid folder from command prompt and launch-hub as follow:

ant launch-hub

Hub will start on port no 4444 as follow:

5. Now start remote server from new terminal from same selenium-grid folder as follow

ant launch-remote-control

It will start as follow:

6. Now in browser go to the hub location by

http://localhost:4444/console

It will look like

7. To start more remote server enter
ant -Dport=5556 launch-remote-control
ant -Dport=5557 launch-remote-control
ant -Dport=5558 launch-remote-control

8. Now the hub on browser will show as

Available Remote Controls
Host Port Environment
localhost 5555 *firefox
localhost 5556 *firefox
localhost 5557 *firefox
localhost 5558 *firefox

Note: The total run time is directly proportional to the number of available remote controls. So don?t start more controls if not necessary.

9. Run the hub

This setup illustrates that you can run the hub and the remote controls on arbitrary machines. When you do so though, you need to provide a lot more information when launching a remote control. You need to launch it with:
ant -Dport=<port> -Dhost=<hostname> -DhubURL=<hub url> launch-remote-control
Where:

port Port that the remote control will be listening at. Must be unique on the machine the remote control runs on. hostname Hostname or IP address of the machine the remote control runs on. Must be visible from the Hub machine. Note: this information could be inferred as it is always referring to the machine the remote control runs on. It might not be required in future versions of the Selenium Grid. hub url Which hub the remote control should register/unregister to. If the hub is running on hostname my.hub.com, this URL will be http://my.hub.com:4444

10. Now to run a test open new cmd prompt and go the test folder.
phpunit Example

11. This will start the test.

Print This Post This page as PDF Email This Post Unit Testing and Selenium Testing

Monday, June 1st, 2009

By Vaishal,

Unit Testing

Unit testing is a software verification and validation method where the programmer gains confidence that individual units of source code are fit for use. A unit is the smallest testable part of an application. In procedural programming a unit may be an individual program, function, procedure, etc., while in object-oriented programming, the smallest unit is a method, which may belong to a base/super class, abstract class or derived/child class.

Ideally, each test case is independent from the others: substitutes like method stubs, mock objects, fakes and test harnesses can be used to assist testing a module in isolation. Unit tests are typically written and run by software developers to ensure that code meets its requirements and behaves as intended. Its implementation can vary from being very manual (pencil and paper) to being formalized as part of build automation.

The goal of unit testing is to isolate each part of the program and show that the individual parts are correct. A unit test provides a strict, written contract that the piece of code must satisfy. As a result, it affords several benefits. Unit tests find problems early in the development cycle.

For the php code we are performing unit testing using PHP Unit.

Selenium Testing

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. It is used for functional testing. Selenium can be deployed on Windows, Linux, and Macintosh.

The latest side project is Selenium Grid, which provides a hub allowing the running of multiple Selenium tests concurrently on any number of local or remote systems, thus minimizing test execution time.