Previous Topic: Create and Export a Selenium Builder RecordingNext Topic: Export a Test Case with Selenium Test Steps to a JSON Script


Import a Selenium Builder JSON into CA Application Test

Use the Selenium Integration test steps to import a JSON test script that you created in Selenium Builder to create a test step or script that is based on that JSON file.

Follow these steps:

  1. Open an existing or create a new test case.
  2. Perform one of the following actions:

    The Import tab of the Selenium Integration page opens.

  3. Click Browse next to the Input JSON Script field and browse to the location of the JSON test script you want to import.
  4. Select one of the following output options:
    Selenium Script

    Imports the complete JSON test script in one test step. This option also supports Selenium Builder suites.

    Selenium Step

    Divides the JSON script to create a separate test step for each action in the script. This option does not support Selenium Builder suites.

  5. Click Build.

    A new step (Selenium Step) or new steps (Selenium Script) appear in your test case.

    The Selenium Integration Import dialog opens. This page notifies you of any warnings or errors that occurred during the import. The page also shows you the number of steps that the import process generated.

  6. Click Close.
  7. Double-click each step to view the JSON script in the Selenium Script or Selenium Step tab of the Elements tree in the right panel.
  8. Complete the following fields for each step:
    Alert Behavior (Optional)

    The Selenium step can provide "inline" alert handling. The fields in the Alert Behavior area work in parallel with the value of the unexpectedAlertBehaviour parameter, which is defined in the file that is named by the selenium.WebDriver.DesiredCapabilities.filePath property.

    These fields let you specify how the test step should react to a modal alert dialog displayed in the web app.

    Alert Action (Optional)

    Defines the action to take in response to a modal alert dialog.

    Values: Accept, Dismiss, Answer

    Input Text (Optional)

    Defines text to input when the Alert Action is Answer. The step inputs the text that you put into this text box, then clicks OK.

    On Step Fail

    Defines the action to take if a specific step in the test case fails. Select the step to execute (Go to:) or the action to take if the step fails. For more information, see Configure Next Step and Generate Warnings and Errors.

    Note: The JSON script supports variable substitution by property for any value that you input. You can also use properties with encrypted values, such as {{password_enc}}, to avoid exposing sensitive data.

     

    The following Selenium Builder steps are mapped to your test case as described:

    Store

    The name/value pair becomes a standard property in your test case. The name is prefixed with "selenium" to distinguish it from other properties. For example, the following JSON definition becomes a new property with the name selenium.window_title. The value is populated after the step runs.

        {
    
          "type": "storeTitle",
    
          "variable": "window_title"
    
        },
    
    Verify

    The verify step in Selenium Builder is used to validate user interface elements. If the validation fails, the state of the step is set to ERROR, but the test case execution flow continues to the next step. An associated DevTest error event (in red) is created for the failure.

    Assertion

    The assertion step in Selenium Builder validates user interface elements. If the validation fails, the state of the step is set to FAIL, and the test case execution flow stops. An associated DevTest error event (in red) is created for the failure.

    saveScreenshot

    If a saveScreenshot step in your script does not include a full path for saving the screen shot, DevTest tries to create the file under a $LISA_HOME\tmp\selenium directory. You can also use variables for the supplied file name. For example:

    c:\testcase1\snapshot1-{{LISA_TEST_RUN_ID}}.png

    or

    c:\{{testCase}}\{{LISA_TEST_RUN_ID}}\snapshot1.png

    If any part of the parent directory for the target file does not exist, that portion of the directory is automatically created. If the target file already exists, it is deleted before writing new data.