Automation Scripts Examples

As a test engineer, you want to test a newly developed web interface. Your goal is to automate test generation, so you don't have to record and edit test scripts in a manual process which could be error-prone. You use the Protractor framework, which produces JavaScript files, together with Selenium. 
ard20
As a test engineer, you want to test a newly developed web interface. Your goal is to automate test generation, so you don't have to record and edit test scripts in a manual process which could be error-prone. You use the Protractor framework, which produces JavaScript files, together with Selenium. 
In this example, you want to test the following workflow for the interface of a web application: 
  • New users can register. The form validates their input, logs them in, and they can access the web application. 
  • Existing users can log in. The form validates their input, and they can access the web application. 
  • The example web application has only one function, users can delete a user, and then log out.
This automation script example contains a flow and automation configuration. 
Overview: 
 
  1. Draw a simple first outline of the flow, with no automation yet, to get a feeling for the model.
  2. Analyse your existing test scripts to identify which variables, objects, and actions you need.
  3. Add objects and actions to your automation configuration.
    For example, you interact with a spinbox in your script, so you need a new 
    setValue(~Number~)
     function.
  4. Update the flow with automation parameters for your blocks.
    1. In your blocks, add the parameters available from the configuration to construct your script.
    2. Go to the flow’s properties, and add variables to your flow that you want to use in the automation steps.
    3. Set these variables’ values in the test data tab for the blocks where they are used, and add them to the automation parameters.
  5. Produce your test cases.
  6. Export your test cases.
  7. Validate that the test cases work. 
Repeat these steps to refine the test flow and resolve issues.
Analyze Existing Test Scripts
You analyze your existing test scripts and determine that they need, for example, the following custom variables of type string:
  • class names and identifiers of buttons and fields
  • URLs of the web app for verification
  • name of browser window title bar for verification
  • test input strings, such as "John" and "Smith"
  • settings for the framework to run your script 
Your flow additionally requires, for example, the following objects and actions:
  • Console — contains code that logs messages to the console.
  • Describe Path — contains code lines that start and end a test suite. It uses the flow attribute 
    ##Path Name[p1]##
     as name.
  • It — contains the code lines that start and end each test spec. It uses the block attribute 
    ##Data Notes[b2003]##
     as name.
  • Browser — contains test actions such as 
    refresh page
     and 
    go to address
    .
  • Element — contains test actions for clicking buttons, verifying if page elements are present, and many more.
  • Form — contains tests actions for filling in and submitting forms.
You also plan to use automation to structure your code, for example:
  • CONFIG — contains the settings that Protractor needs to decide how to run your tests, for example, the type of browser and how to write run result reports.
  • PREVIEW — contains a header and footer that can be added when previewing a particular block's code snippets.
Build your automation configuration
After the analysis, you have identified what you need: objects, actions, and variables. Based on that, you create your custom automation configuration.
Follow these steps:
 
  1. Create a detailed flow for registering and logging in a user to a website.
    Tip:
     Load User_Registration.vtf to see an example.
  2. Click 
    Tools, Properties
     and define variables. Save and Close.
  3. Click 
    File, Configuration, Automation, Objects and Actions
    . Define actions for your objects. Save and Close.
    Tip:
     Load User_Registration_Auto.config as an example.
  4. (Optional) Create a "Create Configuration" flow.
    This extra flow automatically generates a configuration file for Protractor.
    Tip:
     Load User_Registration.vtf to see an example.