Show TOC

Procedure documentationWorking with Message Parameters

 

To retrieve data from messages for the test automation of Web and Web Dynpro scenarios, you can use message parameters.

You can retrieve information from a message that the application displays in the message area, with the default component CBTA_WEB_A_GETMESSAGEPARAMS. This component is not used by default when you record the tested business scenario. As the test engineer, you must manually add it to the generated test script. It allows searching the message area for a message. The message sentence must match the pattern that is specified as input parameter. The sentence is parsed and its fragments are exposed as output parameters.

Example Example

The Create Shopping Cart scenario typically ends with a message that informs the user about the creation status. This message contains the number of the new shopping cart. You retrieve it and pass it to the subsequent steps of the test script.

End of the example.

Prerequisites

You have installed and configured CBTA 3.0 SP02 or higher.

You have SAP Solution Manager 7.1 SP10 or higher.

Procedure

Default Component CBTA_WEB_A_GETMESSAGEPARAMS
  • Input Parameters

    • URI (optional): the URI identifying the message area

      If empty, the component searches for the message in the main document of the main window of MS Internet Explorer.

    • MessagePattern: the pattern that the message must match

    • Options (optional): /u (uppercase) to ignore the case when using the pattern

  • Output Parameters

    • MessageText: provides the full message text

    • MessageParameter1: provides the fragment matching placeholder {1}

    • MessageParameter2: provides the fragment matching placeholder {2}

    • MessageParameter3: provides the fragment matching placeholder {3}

    • MessageParameter4: provides the fragment matching placeholder {4}

  • Placeholders

    The syntax of the message pattern can include placeholders to extract some words from the text that is displayed in the application:

    • {?}: matching one or more words. Use this placeholder to ignore part of the text.

    • {1}: matching one or more words and exposing them by MessageParameter1

    • {2}: matching one or more words and exposing them by MessageParameter2

    • {3}: matching one or more words and exposing them by MessageParameter3

    • {4}: matching one or more words and exposing them by MessageParameter4

Example Example

To retrieve a shopping cart number you can use, for example, the following message pattern:

Shopping cart "{?}" with number {1} saved successfully

With this pattern, the words providing information about the user and the date are ignored, and the shopping cart number is exposed by the output parameter MessageParameter1.

Alternatively, you can retrieve the information with the following syntax:

Shopping cart "{1} {2} {3}" with number {4} saved successfully

In this case, we get the following output parameter values:

MessageParameter1: TESTER_01

MessageParameter2: 20.09.2013

MessageParameter3: 22:02

MessageParameter4: 1000133807

End of the example.
Configuring the Test Script
  1. Configure the test script.

    In the Create Shopping Cart scenario, the application is embedded in a portal page.

    The recorded scenario ends with the message that contains the shopping card number. By default, there is no step to retrieve the shopping card number that we need, to check whether the test execution fails. If you have defined a checkpoint during recording (using the Check Picker), it fails because message text contains information that always changes, for example the date and the time.

  2. To retrieve the URI of the message area, use the object spy.

    Note Note

    CBTA uses the URI to identify UI elements in the HTML content. For most of the components, the value of the URI parameter is automatically populated by the test recorder and does not need to be adapted. The message area is an exception. The messages that are displayed here do not have stable IDs and they cannot be found using the regular approach.

    End of the note.
    1. To start the object spy, in the Test Composition Environment, choose Get Technical Information.

    2. Specify the message area.

      HTML attributes and properties are displayed in a tree. In our example, the Create Shopping Cart application is a WebDynpro (ABAP) application based on the Unified Rendering (Light Speed) framework. The URI of the message area is provided in the Light Speed context node of the tree. For more information, see Creating a Login Schema.

  3. Adapt the test script:

    1. If you have defined a checkpoint during recording, disable the CBTA_WEB_CHECKPROPERTY component.

    2. To invoke the CBTA_WEB_A_GETMESSAGEPARAMS component, add a new step.

    3. Specify the URI of the message area that you have determined, with the object spy.

    4. Use placeholders to extract the required fragments from the text of the message.

  4. To check whether the message data is retrieved correctly, execute the test script.

    The CBTA_WEB_A_GETMESSAGEPARAMS default component retrieves the information from the message and makes it available to subsequent steps by its output parameters. The information is displayed in the execution report.

    For more information about using output parameters, see the CBTA How-to Guide at http://wiki.scn.sap.com/wiki/x/kQ_IFQInformation published on SAP site.

The same information is also accessible using the concept of tokens, as shown in the last graphic. Tokens pass information between components. All component parameters (including the URI parameter) can use tokens. Each time a component starts, the runtime library looks for tokens and replaces them with the value of the corresponding variable. For more information, see the CBTA Default Component Guide at http://wiki.scn.sap.com/wiki/x/kQ_IFQInformation published on SAP site (under Test Option 1).