Our vBulletin migration is complete.
Welcome vBulletin users! All content and user information from the Micro Focus Forums (vBulletin) site has been migrated to this site. READ MORE.

Customization of form data from script using a csv file

Customization of form data from script using a csv file

This video demonstrates how to parameterise the form values in your script so that you are reading unique data for all users from a csv file.

 

 

This demonstrates how to parameterize your script so you’re reading unique data for all users in your test from a csv file.  It uses a script which has been recorded against a demo application called ShopIt, which is a sample e-commerce application.

The dclform section in the script contains data which has been entered into forms within the application during record.  It is common to record with one set of data but to want to use different data for each virtual user in your test.  This demonstrates how you would modify the form values to use unique data for each user from a csv file.

The Username is entered into the Application during record.  We can customize this as follows:

  • Highlight the value
  • Right-click
  • Select the ‘Customize Value’ option from the pop-up list.
  • The Parameter Wizard opens to guide you through the parameterization. With it you can modify script values in one of two ways:
    • Use an existing parameter that’s already defined in your script
    • Create a new parameter.

   We select the option to create a new parameter.

  •  The next screen allows you to select the type of parameter.
    • Constant value will use the same value for all users throughout the test.
    • Parameter from Random file allows you to define a random variable.
    • Parameter from Multi-column data file.  This option enables you to generate a data driven test which will allow you to store all user data for a test in a single file, for example username, password, address and so on. This is the options we will follow.
  • In the next screen you can either create a new file using this button, or you can choose a file from the dropdown list. 

The contents of this list are taken from the SilkPerformer ‘Data’ folder, and this is also where you should place any custom data files you wish to use for your tests. Here you can also see the handle that will be used to refer to the file within the script, and also the parameter name.  For this test we will select a file that we had already created.

  • In the first column we can see our list of usernames, and so we highlight this column.
  •  After clicking Next, we must select how we wish the data to be used within the test.

Firstly, the row selection order:

Random means that there will be no pattern to how the rows are accessed during the test – users will just randomly select a row from the file.

Sequential - machine-wide – Users on each agent machine used in the test will access the rows in a sequential fashion.  The pointer is not held across agents, and so users running on different agents will be accessing the same rows of the file.

 Sequential  - Test-wide – each user in the test, regardless of agent machines, will be accessing the rows in the file sequentially.  The handle is held globally across all agents, and users will all be accessing unique rows.

 

  • Select ‘Sequential  - Test-wide’ to ensure that all users use unique data across all agents.
  •  In the Attribute section you can specify if you want a user to keep the same value for the duration of the test, or if they should pick a new value on each iteration of the transaction.

 Now, when we look in the script we can see where we load the file in the initial transaction – Tinit.

If we had selected that ‘per test’ attribute rather than ‘per transaction’ in the last step of the wizard, we would also see the functions for accessing the rows of the csv file in TInit.  Instead, as we selected ‘Per Transaction’, these functions are scripted in TMain.

Firstly the FileGetNextUniqueRow function.  This function is the one used to create a Sequential test-wide unique pointer to the row after the current row. 

 If we had selected Random we would get the FileGetRndRow function scripted here instead, and for Sequential machine wide we would see the function FileGetNextRow.

 After the current-row pointer is set with the appropriate function, you can access the columns of the row with the FileGetCol function.  This function outlines the column we have selected from the csv file.

We also see there has been a shutdown transaction created, and here we have the function to unload the csv file again at the end of the test.

In the dclform section we can see the original code which specified the username has been commented out, and a new line has been entered referencing the variable we have just created.

As discussed earlier the same csv file can be used to store all information relating to your test.  To reuse the same csv file in your test:

  • Again highlight the value we wish to customize, in this instance City
  • Right-click and select Customize Value.
  • Create a new parameter from a multi-column data file.
  • Click Next to have the option to either ‘create new’ to specify a new csv file which we haven’t yet used in this test, or, use an existing file.  The list shows any files which have already been used.  Here we will select the file we have already used to customize the Username.
  • In the next screen the File name and handle have been grayed out, as we have already specified to use the loaded file. The parameter name has of course changed.
  • Select the column that we wish to use for our next set of data.
  •  In the next screen all options are also grayed out.  When you are creating a new parameter based on the file used for another the option no longer exists to use it in a different way; it must use the same configuration options as the original parameter.
  •  Looking in the script we can see that the functions have been added to call the second column from the csv file in a sequential order across the agents.

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2012-11-12 07:53
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.