Adding a Locator on-the-fly in Visual Test
This article discusses how to create a locator on-the-fly that can receive its data from an input parameter that may be driven from Active Data.
1. From the Parameters field of the Properties window, select 'Parameters', then select the 'Add Parameter' icon
For the purposes of this article we have used the locator spy to get the text of the button we are going to create the locator for and have used it as an initial value.
2. Although we are adding only a single locator we are going to place all of the required text into variables. This is not absolutely necessary - the required text could be added directly in step 5 but in the case of creating multiple locators this method is both quicker and cleaner. For this we need three variables: the start of the locator (sLocStart), the end of the locator (sLocEnd) and the complete locator (sLocator). Select 'Start | Right-click | Insert | Variable | Add Local and add the three variables in turn as shown:
Note that sLocator has no initial value.
3. Select the line above where you want the locator inserted
4. Select Start | Insert | Expression
5. Create the Expression as shown: note that sButtonName is not available on the 'Select a variable' dropdown and needs to be added manually into the Expression
Click 'Test' to check the syntax
6. In 'Test Steps',select a control of the same type (here it's a dombutton from Step 14) and Copy it
7. Highlight the line above where you want the new control (Step 8) and Paste it
8. In the Properties window select the 'Locator' line
9. From the elipsis button dropdown, select 'Variable'
10. From the dialog box, select 'sLocator' and 'OK'
11. Your Test Step 9 should now look like this:
This Visual Test was modified for the Login button on the Borland Insurance demo website http://demo.borland.com/InsuranceWebExtJS/index.jsf.