Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
christophe_garcia
Discoverer
This blog will guide you through the creation of a simple monitoring scenario for Synthetic User Monitoring in SAP Cloud ALM for Operations.

Prerequisites

To create your simple SUM scenario with SAP Cloud ALM, you need to follow these 3 main steps:

  • Create the script with Selenium,

  • Upload the obtained script in SAP Cloud ALM,

  • Create and configure the SUM monitoring scenario in SAP Cloud ALM.


1. Create the script


1.1. Record the sequence


In a web browser configured for Selenium IDE:

  1. (Recommended to appropriately record the logon) Clean-up the environment to ensure no open session exists.

  2. Open the Selenium IDE.
    This opens the Selenium IDE application and the welcome popup.

  3. Choose Record a new test in a new project.

  4. Give a name to the project. (E.g. Fiori Launchpad) and click OK.

  5. Indicate the URL for your Fiori Launchpad and click START RECORDING.
    E.g. https://<host:port>/sap/bc/ui2/flp?#Shell-home
    This opens a new browser page, normally on the logon page of the Launchpad you want to monitor.
    If you are directly logged on, likely your script-creation environment is not properly prepared.
    For instance: your SSO was automatically applied because your browser session was already connected.

  6. Fill-in the credentials and type <Enter>.
    You are logged on the Launchpad.
    And in the Selenium IDE UI, you can see that your actions were recorded.

  7. Add a wait for element visible to ensure, at runtime, that the logon is successful.
    For instance, in the Launchpad:

    1. Put the mouse cursor over a tile and open the context menu (right click).

    2. Select Selenium IDE → Wait For → Visible.
      This adds a wait for element visible in the Selenium IDE.

    3. Hint: the added command is not fully valid. It misses to indicate the maximum amount of time to wait (in milliseconds).
      In the Selenium IDE, in the wait for element visible command, set 30000 in the Value field.



  8. (Optionally) record some navigations.

  9. In the Launchpad, click the profile icon and click Sign out.

  10. Click OK in the confirmation popup.
    You are now signed out.

  11. Like in step 7, add a wait for element visible on the goodbye screen.
    (Do not forget to manually add the maximum amount of wait time)

  12. In the Selenium IDE, stop the recording.

  13. Choose a name for the sequence (test) you created.

  14. (Optional) You may want to save your temporary script.
    This will create a SIDE file.






    Warning
    At this moment, the SIDE file you save still contains the logon credentials in clear.



1.2. Check and adjust the recorded sequence


During the recording, Selenium IDE recorded all the actions you performed on the UI.

It's now time to replay the sequence and, if required, adjust it by:

  • Adjusting the commands target,

  • Adding missing actions,

  • Deleting useless actions.


After modifying the script, it's advised to attempt to replay again the sequence to verify that everything is correct.

1.2.1. Replay the sequence


In Selenium IDE, click the Run current test button.
A browser session is opened and the script is executed.
It could be that Selenium IDE replay fails on an error like:
"A listener indicated an asynchronous response by returning true, but the message channel closed before a response was received."
Generally, SUM can handle that properly. In Selenium IDE, you can avoid the error by:




  1. Setting a breakpoint of the faulty action by clicking on the row number of the corresponding command.

  2. Executing the script normally by clicking the Run current test button.

  3. When the execution pauses on the faulty command, wait for the application to display the screen.
    Then either:

    1. Continue the execution automatically by clicking the Resume test execution button.

    2. Or continue the execution command-by-command by using the Step over current command button.






1.2.2. Adjust the commands targets


During the recording, Selenium IDE tried to figure out the best way to identify the target element for the actions.
It supports may ways to identify elements: id, css selector, xpath, ...

This corresponds to the Target field of the commands.

Generally, Selenium IDE tries to propose several options. The main one is the one you see in the UI. But you can see the others via the Target filed dropdown.


If during the replay, an element cannot be found despite the fact it is visible in the browser, you may want to adjust the command target.

  • Option 1 - Have Selenium IDE try to propose another target automatically,

  • Option 2 - Define yourself a new target using one of the identification methods supported by Selenium IDE.


1.2.3. Add missing actions


During the recording, you may have missed some actions. E.g. some Wait for ...
You can edit the sequence to add them.

For instance, you may want to wait for the login screen to be displayed before trying to preform the logon.
You can add the missing commands:

Either manually ...

In Selenium IDE:

  1. Select the command that should follow the missing action

  2. In the context menu, choose Insert new command
    This adds a new empty command.

  3. Select the new command row and fill-in the Command field.
    Choose wait for element visible.

  4. Then fill-in the Target field.
    You can either enter it manually or use the Select target in page button.
    In our case, "wait for the login screen to be displayed", we already know a possible target: we can use the same than the one of the type command used to type-in the username.

  5. (Optionally) You can try the entered target by clicking the Find target in page button.
    This will highlight the targeted element.


... or by recording the missing actions.

In Selenium IDE:

  1. Put a breakpoint on the command that should follow the missing action.

  2. Execute the sequence by clicking the Run current test button.
    The execution will halt just before the execution of the command.

  3. Stop the execution by clicking the Stop test execution button.

  4. Click the Start recording button.

  5. Record the missing actions.

  6. Stop the recording by click the Stop recording button.
    The commands have been inserted in the sequence.
    (For the wait for ... commands, do not forget to indicate the maximum wait time in the command Value field)


1.2.4 Delete useless actions


During the recording, you may have performed some useless actions that Selenium IDE recorded.
You may not want to keep them in the sequence. For that:

  1. Identify the useless commands.
    For instance, by replaying sequence step-by-step.
    E.g. During the logon phase, the click on the username field is generally useless (like the click on the password field).

  2. Select the command to remove.

  3. In the context menu, select Delete.










    Warning

    Selenium IDE does not have "undo" on the command delete. Be careful when deleting commands



1.3. Prepare the script for SUM


1.3.1. Adjust the Test suite name


When the SIDE file is imported in SUM, the scenario name is the one of the Test suite.
By default, Selenium IDE names the Test suites "Default Suite".

To have another name for your script, in Selenium IDE:

  1. Go to the Test suites section.
    You can see the Default Suite Selenium IDE created.

  2. Click the 3 vertical dots to open the context menu (put the mouse cursor above the Default Suite to see them).

  3. Choose Rename.

  4. Enter a new name and click RENAME.



1.3.2. Define the SUM steps


During the Scenario execution, SUM captures metrics for all the SUM steps.

By default, the script defines only one step.

Here I would like to have several steps for each functional actions in the recorded sequence:

  • Entrance → the opening of the application URL,

  • Login,

  • Logout.


The first (default) SUM step is named after the name of the Selenium Test. Currently named myTest.
To change the Test name, in Selenium IDE:

  1. Go back to the Test section.
    You can see the test you created at the end of the recording.

  2. Click the 3 vertical dots to open the context menu (put the mouse cursor above the test name to see them).

  3. Choose Rename.

  4. Enter a new name and click RENAME.


For the next SUM steps, you can use the SUM annotation @Sap.sum.step="your step name"
c.f. SAP Cloud ALM for Operations Expert Portal → Synthetic User Monitoring → Creating Synthetic User Monitoring Scripts # Add SUM Steps to Selenium Tests

For instance, to declare a SUM Step for the Login phase:

  1. Select the first command of the Step.
    In our case, the type of the user name.

  2. In the command Description field, enter @Sap.sum.step="Login"


Do the same operation for the Logout step which, in our case, starts with the click command on the id=meAreaHeaderButton









Hint

It's advised to end a step with a Wait for ... command to ensure that the monitored UI displays the correct information before continuing with the next step (or finishing the script)




1.3.3. Declare the SUM variables


You may want to have field not hardcoded in the Selenium script but fed by the SUM Scenario configuration.
This is typically the case for the sensitive information like the credentials.

To have a SUM variable for the login password of our example, in Selenium IDE:

  1. Select the type command where the password is entered.

  2. Replace the Value field with a dummy value.









    Note

    If a replay is attempted in Selenium IDE, it will be required to temporarily set again the actual password.



  3. In the Description field, add the @Sap.sum.secure.variable=password SUM annotation.


For more information about the SUM variables, c.f. SAP Cloud ALM for Operations Expert Portal → Synthetic User Monitoring → Creating Synthetic User Monitoring Scripts # Define SUM Variables in Selenium Tests

Your script is ready, you can save your project.

This creates the SIDE file to import in SUM.

2. Upload the script as a SUM resource



  1. Logon to your SAP Cloud ALM tenant.

  2. Start Synthetic User Monitoring.

  3. Open the configuration panel and, on the Resources section, enter the edit mode.
    This opens the SUM configuration popup.

  4. Click the Upload button.

  5. Browse to the SIDE file you created.

  6. Click Upload.

  7. The Upload Report popup lists the scripts SUM detected in the SIDE file.


Your Selenium IDE script (SIDE file) was now imported and is visible in the resources.



3. Create and configure the SUM monitoring scenario


In the Synthetic User Monitoring Configuration popup:

3.1. Create a new Scenario using the script you previously created



  1. Go to the Scenarios section.

  2. Click the Add button.
    This opens the Add Scenario popup.

  3. In the General section, choose a name for the scenario and enter a description.
    By default, the new scenario will be automatically added to your SUM scope.

  4. In the Execution section, use the drop-down to select the script you imported via the SIDE resource.

  5. In the Business Services section, select a business service to associate your scenario to.
    This is used to indicate which applications are monitored by your scenario.
    If you don't have specified business services yet, you can use the SUM default one.

  6. Click the Add button.


Your new scenario is now created. You still have to configure it.

3.2. Configure the SUM variables


In the Scenarios list:

  1. Click on the scenario you created.
    This opens the Scenario Details.

  2. Go to the Variables tab.

  3. Enter the variable values to use at execution time. For instance, enter the value for the password variable you defined during the script creation.

  4. Save.


3.3. Associate the Scenario to a Runner


In the Scenario Details:

  1. Go to the General tab.

  2. In the Runners section, click the Assign button.
    This opens the Assign Runners popup.

  3. Select one (or several) Runners to assign to the Scenario, then click Assign.
    The popup is closed and the runner is added to the list of Assigned Runners.

  4. Activate the Scenario on the Runner.

  5. Save.


The Scenario is now scheduled to be regularly executed on the Runner.
Because you already added the scenario in your SUM Scope during the scenario creation, the SUM overview displays your new scenario.



3.4. (optional) Adjust the time interval between two executions


In the Scenario Details:

  1. Go to the Scheduling tab.

  2. Untick the Use default checkbox.

  3. Change the Execution Period.
    E.g. set 900 (900 seconds interval) for an execution every 15 minutes.

  4. Save.


3.5. (optional) Enable the capture of screenshots during the execution


In the Scenario Details:

  1. Go to the Selenium tab.

  2. In the Screenshots section, for the Automatic screenshots field:

    1. Untick the Use default checkbox.

    2. Choose At each step in the drop-down.



  3. Save.


You now learned how to create a simple Synthetic User Monitoring scenario to monitor a SAP Launchpad.

Stay tuned for additional blogs on how to create such a Selenium script.

In the meantime, I look forward to your feedbacks.

 

For additional information on SAP Application Lifecycle Management, have a look at the dedicated community topics page: https://community.sap.com/topics/application-lifecycle-management
1 Comment