Automation Scripts Examples
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.
- Draw a simple first outline of the flow, with no automation yet, to get a feeling for the model.
- Analyse your existing test scripts to identify which variables, objects, and actions you need.
- Add objects and actions to your automation configuration.For example, you interact with a spinbox in your script, so you need a newsetValue(~Number~)function.
- Update the flow with automation parameters for your blocks.
- In your blocks, add the parameters available from the configuration to construct your script.
- Go to the flow’s properties, and add variables to your flow that you want to use in the automation steps.
- Set these variables’ values in the test data tab for the blocks where they are used, and add them to the automation parameters.
- Produce your test cases.
- Export your test cases.
- 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 asrefresh pageandgo 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:
- Create a detailed flow for registering and logging in a user to a website.Tip:Load User_Registration.vtf to see an example.
- ClickTools, Propertiesand define variables. Save and Close.
- ClickFile, Configuration, Automation, Objects and Actions. Define actions for your objects. Save and Close.Tip:Load User_Registration_Auto.config as an example.
- (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.