Skip to content
Sahi Pro Flowcharts is retired. These pages document the last release (v12) and are no longer updated. Go to the current documentation.Flowcharts is retired. Current docs
Get Free Trial
Sahi Pro Flowcharts is retired. These pages document the last release (v12) and are no longer updated. Go to the current documentation.

Negative Validations

Applications should correctly reject invalid data and show meaningful error messages. Negative Validations are test flows that input such invalid data and verify the error messages.

The values we need to check for Negative Validations can be derived from various sources:

  • Requirement documents
  • Standardized documents like RFCs etc.
  • Validation error messages
  • Prior experience / common sense

In the User Registration case, let us see what validation messages are shown.
Navigate to the registration page manually and click on Submit without entering any value.

The following error messages are seen:

Errors

This suggests that we could check for blank name and names with more than 32 characters for First Name.

  1. Navigate to Automate → Entities → Select Entity $user → Select Attribute firstname

  2. Choose Negative Validations tab

  3. Add values to check for under Input Value column. Let us check for an empty value. Leave the Input Value empty.

  4. Add the Error Message that should be visible on the UI.

    1. You can either copy paste this from the application UI or from documentation
    2. If you want to get it from the UI, you can Ctrl + Mouse Hover on the error message on the UI. The message will appear in the text box at the left bottom. You can copy paste from there.In this case, the error message is “First Name must be between 1 and 32 characters!”
  5. We can add a comment about the value for further clarity. Eg. “Should not be blank”.

    Negative Validations Data

  6. Add one more row for a character string with >32 characters Thisislongstringwhichshouldnotwork, as shown in the image

  7. Click Save Entity to save

As mentioned above, we will also need to know the UI Element where the input will be made, and the UI Error Element where the error message will appear.

  1. Navigate to the UI Element sub-tab

  2. It should already be populated with UI Element for First Name Input
    If not already populated, go to the application and Ctrl + Mouse Hover on the First Name textbox.
    The UI Element textbox at the bottom will get populated. Drag the value onto the UI Element column.

  3. For UI Error Element, we will Ctrl + Mouse Hover over the error message. We notice that the identifiers are either using the error text itself or are using a generic css classname.

    First Name UI Elements

    Let us use the anchor button to get a better identifier.

    1. Navigate to the Opencart window, Ctrl + Mouse Hover on Label First Name. A red outline highlights the label and it appears in the UI Element box.

    2. Click on the Anchor button.

      Identify Label

      The Anchor button gets an orange line at the bottom to show that it is on.

    3. Navigate to the Opencart window, Ctrl + Mouse Hover on the error message for the First Name.
      A red outline highlights the error message and it gets added to the UI Element box.

    4. Click on the drop-down arrow next to the UI Element box. It shows the various identifiers.
      Notice that the identifiers use _near(_label("First Name")) to show that we are identifying the error message box relative to the First Name label.
      Using _near, _in, _under etc. makes the identifiers more resilient to changes in the application UI.

    5. Select the option _div("text-danger", _near(_label("First Name")))

      Identify Element using Anchor

    6. Drag the UI Element box and drop to the UI Error Element.

      Drag & Drop UI Error Element

    7. Click the Anchor button again to turn of relative identification.

We have set both the UI Element and UI Error Element

For some types of values, Flowcharts can suggest possible invalid values to check for.
For example, an email is of a standard format no matter what the application is.
So Flowcharts provides suggestions for such standard data types.

Let us add Negative validations for $user.email.

  1. Navigate to Automate → Entities → Select Entity $user → Select Attribute email

  2. Choose Negative Validations tab

  3. Click on Suggest button.

  4. Select datatype email

  5. A long of list of values are shown with comments. For now, select the first two suggestions.

  6. Click on Add button.

    Invalid value suggestions for Email

    These values get added to Negative Validations.

  7. Identify the error message from Opencart window with Ctrl + Mouse Hover method.

  8. Copy the identified error message and paste into the Error message column for both the rows.

    Error Message for Email

  9. Make sure to also add UI Element:_emailbox("email") and UI Error Element:_div("text-danger", _near(_label("E-Mail"))) for email

    Email UI Elements

  10. Click Save Entity to save

  1. Check for the path settings:
    Click on path tab and select the checkbox for Enable Validations.

    Path Enable Validations

  2. Click on the Run button.

    Run button

  3. Run Settings dialog opens. Select the checkbox Run Negative validations only and deselect others.

  4. Click on Run button.

    Select Run Positive Validation

Follow the steps to check the Report after running/executing the Negative validations :

  1. Click on the Reports button.

    Report Button

  2. The Report window will open in a new tab.

  3. Click on Registration P0 NEGATIVE VALIDATION.

    Suite Report for Negative Validations

  4. Suit Report tab opens. Click on Registration P0 NEGATIVE VALIDATION.

    Script Report for Negative Validations

  5. It opens the Script Report tab. Click on Expand All to view details of each attribute, or click on each validation to see its details.

    1. Report for the case where firstname is blank

      Expanded Script Report for Blank Negative Validations

    2. Report for the case where firstname is more than 32 characters long

      Expanded Script Report for 33 Characters Long Negative Validations

    3. Report for the case where email address is not correct

      Expanded Script Report for Email Negative Validations

Next: Loop over Dataset