Editing a MITE script

Scripts can be edited after recording. You may want to modify a script so that it can be used with websites that change frequently, or for other reasons.

Mobile Web Perspective and MITE use a scripting engine based on Mozilla SpiderMonkey.

Actions can be added to scripts to deal with special requirements, like validating that a web page has a certain object. See this help page for information on adding actions to scripts.

Scripts can be edited in basic script view, or advanced script view.

Basic script view

In the basic script view, script steps are shown in block format, with details about each script action displayed in the Script Action Properties panel as a action is selected.

Many attributes of script actions can be modified by making selections or editing text values shown in the Script Action Properties panel.

After making changes to the script, you should run the script to validate that it works as intended.

Script editing tools

Script editing tools for cutting, copying, pasting, undoing/redoing edits, and commenting out lines are available at the page as well as action levels. Right-click an action or page in your script to view the edit toolbar. When you cut or copy a line(s), you have the option to select another action/page and paste above or below it. Commenting out enables you to test variants of your scripts without having to re-record. A line that has been commented out is displayed in green, as shown below.

Editing script and action parameters in basic view

Each script action shown in the basic view can be edited after recording using the Script Action Properties panel at the right.

For example, in the example shown above, the "Click the link" action shown in Page 2 is represented in the Script action properties panel as a ClickOnLink action. For the corresponding target element, you can edit the name (link name), Id, url (target for the link), Access key (any HTML accessKey that has been defined for the link), and other attributes. You can use xPath commands to specify any node of a web page.

You can also edit the Element position (the position of the link on the page) and Element parent description (parent attributes).

Completion events

Completion Events provide a way to specify when an action has been completed so the script can proceed to the next action (or complete playback). In MITE, every action that generates network activity has a completion event. You can add multiple Navigate actions to a single script page—each one will have a completion event.

You can edit completion events after recording your script. More than one completion event can be selected per action; the action is considered completed when all have been met. We recommend using a load event combined with network inactivity or combined with End on specific content (it does not make sense to combine a load event with ending on a specified URL or URL count).

The default completion event created for every action in MITE is a combination of network inactivity of 2 seconds and End on load event = True (download cycles).

Set Use Completion Event to True. The available completion events are:

  • End on specific content - If true, the action is completed either when specific text from the page or an element from the DOM is displayed. You must specify these details:

    • Content text - Text to locate on the page; leave empty if waiting for a DOM element (see Location in the DOM below).

    • Wait content to disappear - Optionally used in combination with Content text or Location in the DOM (e.g., if the content appears briefly on the page). If true, the content must disappear for the action to be completed.

    • Location in the DOM - Use XPath commands to specify the element to look for. Do not specify Content text if using this option.  To locate the element's path expression:

      1. Run the script in MITE (Home > Run).

      2. Navigate to Run results using the left button bar.

      3. Select the DOM tree view tab on the right.

      4. Locate your element in the DOM tree.

      5. Right-click the element and choose Copy XPath.

      6. Right-click to paste the element's path expression in the completion event.

  • End on URL count - If true, the action ends when the specified number of HTTP requests have been received.

    • Number of URL - Number of HTTP messages to be received before an action is considered complete
  • **End on load event ** - MITE waits for the browser's internal "Finish" event (download cycles) before completing the action. This completion event is set by default to True. Use in combination with End after HTTP inactivity or End on specific content.

  • End after HTTP Inactivity - If true, MITE waits for network inactivity of the specified amount of time before completing the action.

    • Time to wait - Milliseconds of network inactivity; set by default to 2000.
  • End on URL response - If true, ends the action when a specified URL, e.g., for a specific image file, has been downloaded.

    •   **URL to wait** - URL to wait for; you can locate the element URL in the **DOM tree view** of **Run results**.
      
      1. Run the script in MITE (Home > Run).
      2. Navigate to Run results using the left button bar.
      3. Select the DOM tree view tab on the right.
      4. Locate your element in the DOM tree.
      5. Right-click the element and choose Copy line.
      6. Right-click to paste the URL in the completion event. Be sure to delete all tag information other than the URL.

Advanced script editing

Selecting the Advanced Edit View displays the script as a plain text file, which can be modified, either directly in MITE or in a text editor. Advanced scripting requires use of the MWP scripting language.

Note

If you modify a script in the Advanced Edit View, the script will not be viewable in the basic script view and you will not be able to use the MITE UI to change action parameters.