Define Your Automation Configuration

Analyze your existing test scripts and identify common headers or footers, code snippets, and variables for each action. After you build a flow for your system, you declare variables and create your automation configuration file. For more information about variables, see How to Use Variables.
ard28
Analyze your existing test scripts and identify common headers or footers, code snippets, and variables for each action. After you build a flow for your system, you declare variables and create your automation configuration file. For more information about variables, see How to Use Variables.
The Step Join parameter makes it possible to use the same set of automation actions 
as statements and expressions
. Statements include an end of line character for the respective language; for example, a JavaScript statement ends with a semicolon and a newline character. Expressions are function calls that you can use as parameters in other function calls; for example, JavaScript expressions do not end with a semicolon.
Choose one of the following options how to join code snippets of Actions.
  • Define code snippets as statements
    End the line in each code snippet, and don't use Step Join.
    Element.click();
     
  • Define code snippets as expressions
    Do not end the line when defining each code snippet, and use the Step Join parameter to control whether a line is an expression or a statement.
    Element.click()
     
You control whether a particular code snippet is joined to the previous and next code snippets by the Step Join or not.
This article covers the following tasks:
 
 
 
3
 
 
Define Automation Layers
(Optional) If you require to export several different script files for one test case, use layers to create separate and independent automation configurations. Each layer can contain its set of objects, actions, variables, and corresponding code snippets in different programming languages. You define an automation configuration for each layer.
When you optimize and store your paths, review the scripts for each layer on the 
Automation 
tab. When you export, each of the layers has a separate tab, and you can export each configuration independently. For example, you can define 
two
 layers to generate a JavaScript file and an XML test data file from 
one
 stored path.
Follow these steps:
  1. Go to the 
    Home
     tab and click 
    Automation
    . Click the 
    Layers
     tab.
  2. Click the 
    Add Layer
     button for each layer
  3. Define properties for each layer:
    • Automation Layer Name
       
    • (Optional) 
      Execution File
      While designing and debugging your automation configuration, you can execute a command-line script or any desired executable for individual generated test paths. To run the script, go to Test Factory, Export Automation, then click the green 
      Execute Script
       button. The executable runs from the local system, this option is not intended for production use.
      Example: 
      C:\MyAutomation\bin\BuildAndRunTCB.bat ##Path Name[p1]##
       
    • Select Language
       — Defines the language of the code snippets for this layer.
    • Select Theme
       — Defines the syntax highlight theme for the code snippets.
    • Select Entry
       — Specifies how you want to enter code snippets.
      • Text
        Enter code snippets for this layer by typing in a text field.
      • Spreadsheet
        .
        Enter code snippets for this layer by pasting from a spreadsheet. For more information, see Import and Export Snippets From Keyword-Driven Spreadsheets.
      Default: Text.
  4. (Optional) Define advanced properties for each layer.
    • Select objects and actions from folder location
    • Automatically map actions from a block attribute — Choose block attributes from which you want to map. For more information how to map automation parameters from block attributes, see How to Use Variables.
  5. Click 
    Close and Save
     and define a file name to save this configuration if prompted.
Define Your Automation
  1. Go to the 
    Home
     tab and click 
    Automation
    , and click the 
    Variables 
    tab:
    1. Create variables, specify default values.
    2. Click 
      Save
       and 
      Close
      .
  2. Go to the 
    Home
     tab and click 
    Automation
    , and click the 
    Export 
    tab.
    1. Select the layer to which this configuration applies under 
      Showing Layer
      .
    2. Define 
      Export Details
      .
      • Choose for each layer whether you want to publish several 
        Separate Scripts
         or one
         Merged Script
        , by default.
      • Define your default 
        File Naming System
        ,
         File Name Variable
        ,
         File Prefix
        , and
         File Extension
         for each layer.
      • Select an 
        Export Codec
        .
    3. (Optional) Define 
      Headers & Footers
      .
      Define these fields if your automation language requires custom code inserted before, after, or between generated elements in merged scripts.
      • Block Header Steps
         — (Optional) Defines a string that is prefixed before each block.
        Shell example 1:
        echo "Starting ##Name[b0]##\n"
        Protractor example:
        it('Name: ##Name[b0]## - Description: ##Description[b1]##')
         {
         
      • Block Footer Steps
         — (Optional) Defines a string that is postfixed after each block.
        Shell example:
        echo "Finished ##Name[b0]##\n"
        Protractor example:
        }
         
      • Path Header Steps
         — (Optional) Defines a string that is prefixed before each path. For example entry point function, or include statements and global variables for merged or individual scripts, respectively.
        C++ Example:
         
        #include "FrameworkObjectidentificationLibrary.h"
        std::String productName = "My application under test";
         int main()
         {
         
      • Path Footer Steps
         — (Optional) Defines a string that is postfixed after each path. C++ example: 
        }
         
      • Path Join Steps
         — (Optional) Defines a string that is inserted between paths.
      • Flow Header Steps 
        — (Optional) Defines a string that is prefixed before each flow. For example entry point function, or include statements and global variables for merged or individual scripts, respectively.
      • Flow Footer Steps
         — (Optional) Defines a string that is postfixed after each flow. C++ example: 
        }
         
      •  
        Step Join Steps
         — (Optional) Defines a string that is inserted between steps. JavaScript example: 
        ;\n
         
    4. (Optional) Define 
      Sections
      . Define these fields if your automation language requires custom code inserted before, after, or between generated sections. For more information about sections, see Generate Non-Sequential Scripts Using Dynamic Configuration.
      • Name
         — Defines the name of the section. Must be unique.
      • Description
         — Defines a note to yourself how you intend to use this section.
      • Step Header
         — (Optional) Defines a string that is prefixed before each step in this section. HTML example: 
        <div>
         
      • Step Footer
         — (Optional) Defines a string that is postfixed after each step in this section. HTML example: 
        </div>
         
      • Step Join
         — (Optional) Defines a string that is inserted between all steps in the section. JavaScript example:  
        ;\n
         
      • Section Header
         — (Optional) Defines a string that is inserted before all steps of the section. Gherkin example: 
        Given
         
      • Section Footer
         — (Optional) Defines a string that is inserted after all steps of the section.
      • Section Join
         — (Optional) Defines a string that is inserted between each instance of the section.
      • Default
         — Designates one or more sections as the default target. This means, every time when you add an automation step to a flow, the step is included in the selected sections by default. You can always change the target section manually when you add an automation step that does not belong into the default section.
    1. Click 
      Save
       and 
      Close
      .
  3. Go to the 
    Home
     tab and click 
    Automation
    , and click the 
    Objects & Actions
     tab.
    1. Select the layer to which this configuration applies.
    2. Use the predefined test objects and test actions, or create custom objects and actions.
    3. Enter 
      code snippets
       for all actions in your flows.
      For more information on formats, see Import and Export Snippets From Keyword-Driven Spreadsheets.
    4. Select the appropriate 
      Step Join
       behavior for this line.
    5. Click 
      Insert 
      at the bottom of the code snippet editor to insert variables into code snippets.
      For more information about variables, see How to Use Variables.
    6. Click 
      Preview Snippet
       (green check mark icon) to preview the code with its variables resolved.
    7. Click 
      Save
       and 
      Close
      .
Example Scenario: Define Automation with Statements
In this example, you want to add an automation script snippet for the First Name input field in an online form. Your code snippets are statements, such as 
foo();
. You use Protractor as the test framework.
Follow these steps:
 
  1. Go to the 
    Home
     tab and click 
    Automation
    . Click the 
    Variables 
    tab.
    1. Create variables, specify default values.
      Example:
       Create a variable named 'first_name' and set its static value to 
      noname
      , or use a Data Painter function to pick a random name from a seed table.
    2. Click 
      Save
      .
  2. Click the 
    Objects & Actions
     tab.
    1. Select the layer to which this configuration applies.
    2. Use the predefined test objects and test actions, or create custom objects and actions.
      Examples:
       "Text field - verify exists", "button - click by name".
    3. Enter custom code snippets for all actions in your flows.
      Note:
       If you cannot enter code snippets, click the 
      Preview
       tab, choose 
      Text
       from the 
      Select Entry
       combobox, and return to the 
      Objects & Actions
       tab.
      Example:
       Our goal is to type the value of the 'first_name' variable into the First Name field of the form.
      • Object type: Text Field
      • Action type:
         
        Input Text
      • Code snippet:
        element(by.model('FirstName')).sendKeys('...');
    4. Deselect the 
      Step Join
       behavior for this line.
      Example:
       Because the code snippets are statements, you do not use Step Join.
    5. Click 
      Insert 
      at the bottom of the code snippet editor to insert variables into code snippets. See Automation Keywords for options.
      Example:
      The following code types the value of the 'first_name' variable into the First Name field of the form.
      element(by.model('FirstName')).sendKeys('~first_name~');
    6. Click 
      Preview Snippet
       (green check mark icon) to preview the code with its variables resolved.
      Example
      :
      element(by.model('FirstName')).sendKeys('noname');
    7. Click 
      Save & Close
      .
Example Scenario: Define Automation with Expressions
In this example, you want to create automation script snippets so that they can be used as statements, such as 
foo();
, as well as expressions, such as 
bar(foo())
.
Follow these steps:
 
  1. Go to the 
    Home
     tab and click 
    Automation
    . Click the 
    Variables 
    tab.
    1. Create variables, specify default values.
      Example: Create the variable 
      ~parameter~
       with the value 
      parameterValue
      .
    1. Click 
      Save
      .
  2. Click the 
    Export 
    tab.
    1. Select the layer to which this configuration applies.
    2. Define the 
      Step Join Parameter
       for the ends of statements. The parameter can be an existing object from the same layer, or free-form text.
      Example: 
      ;\n
      Default: Empty string
    3. Click 
      Save
      .
  3. Click the 
    Objects & Actions
     tab.
    1. Select the layer to which this configuration will apply.
    2. Create custom objects and actions for all actions in your flows. Define code snippets as expressions. For example:
      •  
        foo()
         
      •  
        bar(~parameter~)
         
    3. Select the 
      Step Join
       behavior for each line.
      Example:
       Because the code snippets are expressions, you enable Step Join before and after actions.
    4. Click 
      Insert 
      at the bottom of the code snippet editor to insert variables into code snippets. See Automation Keywords for options.
    5. Click 
      Preview Snippet
       (green check mark icon) to preview the code with its variables resolved.
      foo();
      bar(parameterValue);
      bar(foo());
    6. Click 
      Save & Close
      .