Case study C: Recording and replaying with JavaScript and some adjustment


This case study uses the Mid Tier operations Login, Create New Incident, and Logout to demonstrate scenarios where the use of JavaScript is required as a part of the Advanced Scripting option available in KITE. The KITE application also supports other scripting adjustments.

To record the script

  1. Start the KITE 4.0 application.
  2. In the Script menu, click Record.
  3. Enter the Mid Tier URL in the dialog box and select OK.
  4. Select New Dynamic Page, and select No.
  5. Provide a username and password on the Mid Tier login screen.
  6. Select Login to open the Mid Tier home page.
  7. Select New Incident.
  8. Select Customer and enter customer data.
    When you enter a Company name in the Company field, notice that the Incident ID is populated.
  9. To start Action 4 Click on field, select Enter.
  10. To enter incident summary information, select the Summary field.
    Click on field and_Enter text in field_ are added to Action 4.
  11. To select an incident impact, select Impact.
    The Script Viewer reflects this selection as Click on field 'arid1000000163 ' and adds it to Action 4.
  12. Select an impact level.
    This action marks the completion of Action 4 and the start of Action 5 as Click on TD.
  13. Select the Urgency list.
    This action is added to Action 5 as Click on field arid1000000162.
  14. Select an urgency level.
    The Script Viewer reflects this selection as the completion of Action 5 and the start of Action 6 by Click on TD.
  15. Select Save.
    Notice that this event is not recorded in the Script Viewer.
  16. Log out of the Mid Tier.
    The Script Viewer, reflects this action as Click on DIV and adds it to Action 6. It also starts Action 7 as Click on DIV TBlogout.
  17. To complete Action 7, click Stop.

To replay the script

  1. Select Play in Internet Explorer.
  2. In the Save Changes dialog box, select Yes and follow the on-screen instructions to name and save the script.

    For this case study, the script is named Login_Create-New-Incident_Logout.

  3. Observe the replay actions as they occur based on the created script.
    Action 1 through Action 6 replays correctly.
    The script starts to time out at Action 7 and eventually an AR System error occurs. This error indicates that the required field values are not specified. An Internet Explorer JavaScript timeout error is also displayed.

Issues

During replay in this case study, the recorded values for each required field in the New Incident form are not reflected by the Script Viewer and are played back correctly. This issue is caused by a lack of support for some Mid Tier forms; in this case, the New Incident form.

Solutions

To correct this issue, replace all of the necessary actions in the recorded New Incident form with an equivalent set of actions in JavaScript by using the Script Viewer and the Script Property Editor.

To resolve the playback issue for case study C

  1. Replace all the recorded actions in the New Incident Form with an equivalent set of actions in JavaScript.
  2. Save the script with a new name.
  3. From the Script Viewer, in Action 4, right-click the 4. AR System Customizable Home Page (Search) Incident (New) action and select Add DOM Script
    The Script Viewer reflects this selection by adding DOM Script as the last line in Action 4.
  4. Modify the DOM Script to allow substitution of recorded actions in the New Incident form as follows:
    1. From the Script Viewer, Action 4, select DOM Script.
    2. In Script Property Editor, select the ellipses (...) to open the Advance Scripting window. 
  5. Copy the following code snippet into the Advance Scripting window.

    //enter a customer id
    var e = document.getElementById('arid303530000');
    e.value = "01000-Test";
    //fire the change event to dirty the field
    var b = document.createEventObject();
    e.fireEvent("onchange", b);
    //send enter key
    var k = document.createEventObject();
    k.keyCode = 13;
    e.fireEvent("onkeypress", k);
    //populate description
    e = document.getElementById('arid1000000000');
    e.focus();
    e.value = "Sample incident for testing";
    e.fireEvent("onchange", b);
    //select impact
    e = document.getElementById('arid1000000163');
    e.focus();
    e.value = "3-Moderate/Limited"
    e.fireEvent("onchange", b);
    //select urgency
    e = document.getElementById('arid1000000162');
    e.focus();
    e.value = "3-Medium";
    e.fireEvent("onchange", b);
    //select priority
    e = document.getElementById('arid1000000164');
    e.focus();
    e.value = "Medium";
    e.fireEvent("onchange", b);
  6. In the Script Viewer, right-click DOM Script and select Move Up to move this line up in Action 4.
  7. Repeat step 6 until DOM Script is in the first line of Action 4. 
  8. Delete the following items from Action 4 by right-clicking each item and selecting Delete:
    • Enter text in the field for customer data
    • Click on field
    • Enter text in the field
  9. Click Yes in the confirm delete dialog.
  10. Move Save DIV from Action 5 to Action 4, below the DOM Script.
    This step allows you to save and create the New Incident as performed by the JavaScript steps.
  11. Delete Action 5.
  12. Select DOM Script in Action 4. In the Script Property Editor, under Context field, enter a value of 2 for Window.
  13. Edit the Delay After Execution property by adding 500 ms Delay msec
    The context of New Incident is in Window 2. The 500 ms delay allows time for the next action after the DOM Script execution.
  14. Save the script as a new file.
  15. Play back the script.
    Note that the script runs successfully, creates the New Incident, and completes all transactions.

Summary

In the scenarios in this case study, one or more field values in some Mid Tier forms and their recorded actions in the Script Viewer did not play back correctly. Replacing these actions with JavaScript statements bypasses the lack of KITE support.

Case study C features the New Incident form and the use case to create the new incident. You can use similar JavaScript approaches in use cases for the Modify Incident or the New Change forms.

Issue

Solution

The replay of entering the required field Customer ID, as recorded in Script Viewer, does not work correctly.

Use Internet Explorer debugger or Developer Studio to find ARID for the Customer ID field, if not known. Use the following JavaScript statements:

  • getElementById and the ARID
  • createEventobject
  • fireEvent with onchange & onkeypress to replace entering Customer ID

Populating the required Summary field, as recorded in Script Viewer, does not work correctly.

Use Internet Explorer debugger or Developer Studio to find ARID for the Summary field if not known. Use the following JavaScript statements:

  • getElementById and the ARID
  • fireEvent with onchange to replace entering text in Summary field

Selecting the required fields Impact, Urgency and Priority, as recorded in Script Viewer, does not work correctly.

Use Internet Explorer debugger or Developer Studio to find ARID for these fields. These IDs have already been recorded in Script Viewer. Use the following JavaScript statements:

  • getElementById and the ARID
  • fireEvent with onchange to replace entering text in Summary field

The above logical group of actions to create a new incident is recorded such that there is more than one-page completion. For example, some are in Action 4, some in Action 5 and the rest, including Save, are in Action 6.

When replaced by JavaScript, you need to move the Click on DIV for Save up and under the DOM Script so that the new incident is saved correctly.

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*

BMC Helix Innovation Suite 25.2