How to create a SUM Selenium Scenario

How to Define SUM Variables and SUM Secured Variables

When you create a Selenium script, you may want to have some Selenium command values set from SUM variables.
This is typically the case for sensitive data like passwords.

For that, you can add a SUM variable annotation in the Description field of the Selenium command.

Such a description is ignored by Selenium. However, when the SIDE file is imported into SUM, the content is parsed and the annotations are detected.

Syntax

SUM supports four types of variable annotations:

  • @sap.sum.variable=<variable_name> – to have the command value field replaced by the specified SUM standard variable value.
  • @sap.sum.secure.variable=<variable_name> –  to have the command value field replaced by the specified SUM secured variable value.
  • @sap.sum.variable.target=<variable_name> – to have the command target field replaced by the specified SUM standard variable value.
  • @sap.sum.secure.variable.target=<variable_name> – to have the command target field replaced by the specified SUM secured variable value.

The authorized variable name characters are:

  • Alphanumeric ([a-z], [A-Z], [0-9])
  • Underscore ('_')

During the Import

During the SIDE file import, SUM will create the corresponding variables in the parameters of the SUM scenario.

The created variable will be of the following types:

  • String for the @sap.sum.variable and @sap.sum.variable.target annotations
  • Secured for the @sap.sum.secure.variable and @sap.sum.secure.variable.target annotations

The SUM variable default value is the value of the "value" (or "target") field of the Selenium command.
If the command has no value, the variable is not created.

Important

For the secured variable, do not keep the sensitive value in the command value field. (It would be stored in clear.)
Replace it with a dummy value.

If the same variable annotation is declared several times, only one variable is created. Its type and default value are those of the last declaration.

If the Selenium command is disabled, the annotation is ignored.

Note

If the SIDE file is reimported and a variable annotation changed or removed, the SUM Scenario will be updated but the deprecated variable will not be removed from the Scenario parameters list.

During the SUM Scenario Configuration

All the created variables are listed in the SUM Configuration, in the Parameters section of the scenario details.

It is required to set the value of the secured variables. (The default value should not be the correct one.)

At Runtime

When SUM executes the scenario, if a command has a variable annotation, SUM replaces its value with the value of the SUM variable before the command execution.

How to Add SUM Steps in a Selenium Script

There are three ways to define SUM steps in a Selenium script:

  • By adding a test in the test suite
  • By calling a test from another test (via the "run" Selenium command)
  • By adding a SUM step annotation in a test command

Test in the Test Suite

During the SIDE import, a SUM scenario is created for each test suite in the SIDE file (i.e. in the SIDE project).

The step starts with the first command of the test.

It ends with the first of the following events:

  • A "run" command creates a new step.
  • A SUM step annotation creates a new step.
  • The end of the test.

The created step name is the name of the test.
The created step ID is the GUID of the test.

Test Called from Another Test

The step starts with the "run" command.

The step, at least, contain all the commands from the called test.
In other words, a called test cannot create new steps:

  • If the called test contains SUM step annotations, they are ignored.
  • If the called test contains "run" commands, they will be executed but no new step is created.

The step ends with the first of the following events (in the caller test):

  • A SUM step annotation creates a new step.
  • The end of the caller test.

The created step name is the name of the called test.
The created step ID is the GUID of the "run" command.

SUM Step Annotation

To explicitly define a new step, you can add a SUM step annotation in the Description field of a Selenium command.

Such a description is ignored by Selenium. However, when the SIDE file is imported into SUM, the content is parsed and the annotations are detected.
Remarks:

  • If the Selenium command is disabled, the annotation is ignored.
  • If the Selenium command is in a nested test (a test called via the "run" command), the annotation is ignored.

Syntax

@sap.sum.step=<step_name>

The authorized step name characters are:

  • Alphanumeric ([a-z], [A-Z], [0-9])
  • Underscore ('_')

A space character is also authorized if the step name is enclosed in double quotes: @sap.sum.step="<step name with space>"

Behavior

The step starts with the command with the step annotation.

It ends with the first of the following events:

  • A "run" command creates a new step.
  • A SUM step annotation creates a new step.
  • The end of the test.

The created step ID is the GUID of the command with the step annotation.

How to Take UI Screenshots During the SUM Selenium Scenario Execution

During the execution of a Selenium scenario, SUM can take screenshots of the monitored application UI.

Important

  • Screenshots must not be taken for screens containing sensitive data. SUM does not store screenshots in a secured storage.
  • Screenshots storage could quickly consume a considerable amount of space in your Focused Run HANA database. (See How long are screenshot kept)

There are three situations in which SUM can take screenshots:

  • Automatically, for each execution
  • Automatically, when an availability error occurs
  • Explicitly, on commands identified by a SUM screenshot annotation

This behavior can be configured in the Scenario details section of the SUM configuration.

Automatically, For Each Execution

SUM does not take automatic screenshots by default.

In the scenario configuration, you can configure it to automatically capture a screenshot for each SUM step of every execution.

When this feature is activated, for each execution, SUM takes a screenshot of the monitored application UI at the end of each SUM step.

Automatically, When an Availability Error Occurs

Alternatively to the automatic screenshot for each execution, you can configure your SUM scenario to automatically capture screenshots when the scenario execution fails due to an availability error.

In this case, SUM takes a screenshot of the monitored application UI:

  • At the end of the command that generates the availability error
  • And at the end of each SUM step (to provide some context for the error)

When the execution is successful or it produces a performance error, no screenshot is captured.

Explicitly, on Commands Identified by a SUM Screenshot Annotation

Besides the automatic screenshots, you can also instruct SUM to explicitly take screenshots when a specific command of the scenario is executed.

For that, you have to add a SUM screenshot annotation in the Description field of the Selenium command.

Such a description is ignored by Selenium. However, when the SIDE file is imported into SUM, the content is parsed and the annotations are detected.

Remarks:

  • If the Selenium command is disabled, the annotation is ignored.
  • If the Selenium command is in a nested test (a test called via the "run" command), the annotation is ignored.

You can disable the explicit screenshots in the SUM scenario configuration. (They are activated by default.)

Syntax

@sap.sum.screenshot

Behavior

If a command has a SUM screenshot annotation, a screenshot of the monitored application UI will be taken just after the command execution.