Task 1: Record and Playback A Web Application Functional Test.

2. From the Tools drop-down menu choose Selenium IDE. A special Selenium IDE window opens above the main Firefox window.

3. Click back to the main Firefox window. Point Firefox to http://localhost:8080/calendar. You will see the Calendar user interface.

4. By default Selenium IDE opens in its recording mode. Selenium IDE is ready to record your use of the Calendar application.

5. Click the New Event menu item. Note that Selenium IDE records two steps: open the Calendar and click on app_6 (the New Event element ID.)

6. Type Work On Homework in the Event text box. Enter today’s date in the mm/dd/yy format (or click the Calendar icon and click today’s date. Then click the Save Event button. You will see the event in the Today’s Events list.

7. As a final step, right click on the Work On Homework entry in Today’s Event’s. Selenium IDE will show commands to assert the event inserted correctly into the Today’s Events list.

8. Click the Record icon in the upper right of the Selenium IDE window to stop recording the test.

9. Notice the Selenium IDE window displays the steps for the test.

10. Next we will see the test operate in play-back mode. Click and drag the horizontal slider in Selenium IDE to the mid-point between Fast and Slow. Click the Play Current Test Case icon in the Selenium IDE window. It can be useful (and entertaining) to see the play-back.

In the above steps you operated the test of an Ajax application using a Web browser. The Selenium IDE reads the Selenese test instructions and operates the test in the Firefox Web browser. This works well when building and debugging tests.

In the next part of this tutorial you will operate the recorded test in the PushToTest TestMaker test automation platform. TestMaker automates operation of the Selenium test, data-enables the Selenium test, produces reports for the operation of the Selenium test, enables the Selenium test to be a step within a larger use case, and repurposes the Selenium to be a load and performance test and business service monitor from the same single Selenium test.

Task 2: Run The Test In A TestNode

The PushToTest console identifies the operating parameters of a functional test, load and performance test, and business service monitor in a TestScenario. Use the TestMaker Editor to define a TestScenario. Find a TestScenario document already created for you in AjaxRIASeleniumTest/Calendar_Functional_Test.scenario.

Choose File -> Open and select the file TestMaker_home/example_agents/AjaxRIASeleniumTest/Calendar_Functional_Test.scenario

TestMaker opens a new controller panel for the TestScenario. The controller panel includes icons to run, pause, and stop the test.

Click the Edit icon in the controller panel to view the source of the TestScenario document. This action opens the Editor.

Editor displays the TestScenario. Use the tabs to view the parts of the TestScenario. For example, the TestScenario defines use of the Selenium test in the Use Cases tab.

The TestNodes tab tells TestMaker to send the Selenium recorded test to the TestNode(s) that will operate the test.The UseCases tab tells TestMaker to run a use case that runs the Selenium test in CalendarTest.selenium.The General tab tells TestMaker that this is a functional test and to run the use case once6. Click the Run button and watch the results.Functional tests run a test as a single user. TestMaker displays check-marks next to each step of the Selenium test that operate successfully. TestMaker shows the amount of time to operate the use case and each step in the Selenium test.TestMaker displays an X mark for a step that fails. Use the Windows menu -> Output command to view the logs to learn the cause of the failure. Click the Local TestNode Error and Local TestNode Output tabs.

Please note: Selenium IDE’s recording of the Calendar test lacks a few important changes to run in TestMaker. We made the following changes to the CalendarTest.selenium:

Add a setSpeed command as the first line. Right click on the first line of the test, choose Insert New Command. Set the command as setSpeed and enter 3000 in the value field. This value is in milliseconds (1000 milliseconds = 1 second.)

Change the base URL to include the domain name: http://localhost:8080/

Add a waitForElementPresent command. This makes sure the test waits until the JavaScript finishes updating the page to show the New Event form.

Add an Open command. This makes sure the assertion tests the main page content, and not just the New Event form content.

Task 3: Make A Data-Driven Functional Test

Task 3 enhances the functional test of the Calendar application from Task 1 and 2 to use a Data Production Library (DPL.) The DPL reads data from a comma separated value (CSV) flat file. The values provide input to the test (id, password, product number for search) and validation data (the Assert-Text-Exists) value.

1. Create a Comma-Separated-Value file. Use your favorite text editor or spreadsheet program. Name the file data.csv. The contents must be in the following form.

A quick explanation: The first row of the data file contains column names. These will be used to map values into the Selenium test.

2. Change the Selenium test to refer to the column of data. In Selenium IDE change test step 4 from:

type, event, Work On Homework

to

type, event, EventName

A quick explanation: PushToTest maps the data from the named column in the CSV data file to the Selenium test data using the name you just entered.

3.Connect the Data Production Library (DPL) to the Selenium test. OpentheAjaxRIASeleniumTest/Calendar_Functional_DataDriven.scenario in the Editor. Click the Use Cases tab.

4. Click the Add DPL link. Set the DPL type to HashDPL. HashDPL reads data from a comma separated value (CSV) file and provides it at test run time to the ScriptRunner. Set the Action to Get Next Row of Data.

5. By default TestMaker runs the use case in a Functional Test once. Click the General tab and set the Repeat value to a higher value to repeat the use case for the additional rows of data in the data.csv file.

6. That’s all! Click the PushToTest Run button and watch the results.

A quick explanation: The TestScenario operates a functional test by running the Selenium test once. The data file we created contains 5 rows of data. Change the repeat value to 5 to have TestMaker repeat the test for each row of data.

Task 4: Repurpose A Functional Test As A Load And Performance Tests

The test we built in Task 3 operated a functional test by a single user. Load and performance testing identifies the scalability index of a target host application by operating a test with multiple simultaneous concurrently running users. PushToTest reuses functional tests as load and performance tests without requiring any change to the test!

1. In the TestMaker window use the File -> Open TestScenario command. Use the file selector to choose AjaxRIASeleniumTest/Calendar_Load_Test.scenario.

2. Click the Edit icon in the TestScenario Controller panel.

3. Set the test to be a load test in the General tab.

The settings tells TestMaker to operate a load and performance test at three levels of concurrently running simulated users (crlevel.) The test operates 1 user, then 2 users, and then 4.

4. That’s all! Click the PushToTest Run button and watch the results.

PushToTest operates the test in 1 concurrently running simulated users, then 2 users, then 4 users. The Real Time Scalability Index contrasts the Transaction Per Second (TPS) for each of the three user levels. A perfectly scalable system will increase TPS in linear proportion to the increase in users. For example, at 2 users doing 0.03 TPS a 4 user level should be twice the TPS, or 0.06 or higher. The above chart shows an application with linear scalability. The Step Times chart shows the amount of time each step took to operate as the test proceeded.

Task 5: Repurpose A Functional Test As A Business Service Monitor

Business Service Monitor (BSM) testing enforces and proves a Service Level Agreement (SLA) by operating a test periodically. For example, a monitor runs a test every 30 minutes. TestMaker reuses functional tests as a monitor with no changes to the Selenium test and one change .

1. In the TestMaker window use the File -> Open TestScenario command. Use the file selector to choose AjaxRIASeleniumTest/Calendar_Monitor.scenario.

2. Click the Edit icon in the TestScenario Controller panel.

This TestScenario runs the test use case as a business service monitor. The monitor operates the test use case every 10 minutes. The monitor keeps running until it encounters an exception.

3. That’s all! Click the PushToTest Run button and watch the results.

The monitor controller panel is a dashboard to the status of the service being tested.

1. In the TestMaker window use the File -> Open TestScenario command. Use the file selector to choose AjaxRIASeleniumTest/Calendar_ScriptDriven.scenario.

2. Click the Edit icon in the TestScenario Controller panel.

A quick explanation: We ran the Transformer utility on the Selenium recording in Task 3. Access the Transformer in the Tools drop-down menu in TestMaker. The Transformer created the TestScenario you just opened.

3. That’s all! Click the PushToTest Run button and watch the results.

Add your own custom logging to a test script using the PTTStepListener. Add the following commands to a Jython script:

Debugging Ajax Applications: Tips and Techniques

Ajax applications provide rich user experiences. In an Ajax application components may update themselves asynchronously. Ajax applications communicate to information sources external to the browser – like the backend server – or even with other components running on the same page. This flexibility challenges the tests we write. Our Ajax tests must work within the asynchronous nature of the Ajax application. And, we often need to make manual changes to the test because of the lack of a standard for Selenium IDE to follow to record an Ajax application.

You may find the following tips and techniques useful:

a) When you are not certain of the state of your test and the application, use a special savePage and saveSource commands. The target value is a file. saveSource saves the current HTML.

b) Set HtmlUnit into “debug” mode. In the Editor use the Options tab to set “Save received responses to temp directory” and SeleniumHtmlUnit log level.