Structuring complex scripts

It is good practice to organize complex scripts into separate scripts, where each script represents a typical user or business process that you want to monitor. For example, create separate scripts that record when a user logs in to a website, or searches for an item. If you organize your scripts according to user or business processes, you can then monitor the response of your web application to these specific processes. Organize a complex script into multiple scripts; then, save scripts together in a collection of scripts called a test suite.

About this task

If you create a complex script, you can organize that script into simple scripts that represent different business or user processes on your web application. Save the scripts together as a test suite. You can then use these scripts to monitor the performance and availability of your web application in response to specific user actions. Ensure there is only one test suite and all tests need to be added into it.

Procedure

To organize your complex script into separate scripts, and save your scripts as a test suite, complete the following steps:

  1. To create a separate script for each user process that is recorded in your script, click Tests > + in Selenium IDE. Give each script a meaningful name that describes the user process and save each script as a .side file, such as load_homepage.side.

    For more information, see Recording a Selenium script.

  2. In Selenium IDE, open a complex script that you recorded previously. Organize your script commands into separate scripts, according to different user actions. Cut commands from the original complex script in the Test Case window and Paste commands into the different Test Case window.

    For example, the complex script example in Recording a Selenium script contains Selenium IDE commands for three different user processes.

    • Open the Cloud APM home page on the IBM Marketplace website.
    • Open the Details page on IBM Marketplace.
    • Open the Pricing page and record when the user opens the registration page for a free trial.

    The user actions are then organized into three different scripts. See Sample script tables.

  3. To put individual test cases into a test suite, change to the Test suite window and add tests to the test suite according to the business logic sequence. Finally, click the Save Project tool to save the test suite and all tests in the test suite to a .side file.

    As an example, consider the logical sequence Load_URL, Select Manage inventory, Select IBM Machine Type. When you add these test cases to the test suite, you first check Load_URL, followed by Select Manage inventory, and then Select IBM Machine Type.

Results

You recorded a set of scripts that you can use to monitor the performance and availability of your web applications.

Sample script tables

Table 1. Sample script for opening the IBM Marketplace page (load_homepage.side)

Command Target Value
open /
verifyTitle IBM Cloud Application Performance Management

Table 2. Sample script for opening the Details page on IBM Marketplace (load_products.side)

Command Target Value
clickAndWait css=ul > #details > a
verifyText css=h2.heading--TERTIARY Feature spotlights

Table 3. Sample script for opening the Purchase and trial registration pages on IBM Marketplace (load_APM.side)

Command Target Value
clickAndWait css=ul > #purchase > a
click link=Try Free