Sample Code - How to print the contents of a table using a BDLT project
Verifying values is key to avoid errors in the program flow and to make appropriate decisions in your scripts. This sample code shows how to print the contents of all table cells by using a BDLT project and is intended to demonstrate how to perform a full table scan and enable data verification.
However, in real situations you may need to verify values in just parts of the table, which is faster than looking at the entire table, so the main purpose of this sample code is to present you with some ideas you can use to adapt your scripts should you need this type of verification.
The first thing to observe is the use of indexes in the locator strings. Here we use the indexes, represented by brackets and a number (or a variable inside the brackets) to refer to specific rows and columns that share the same basic xpath locator. These brackets are not shown when you use the locator spy in Silk Performer browser application, but they are conceptual and related to the xpath syntax.
How to use the sample code
The sample also has key variables for you to understand:
The nRowIndex means the first row in the table to be scanned. If your actual table has headers, then you might consider changing it to 2, so the scan starts at the second row.
The nColIndex has a similar meaning. In this example, it means what’s the first column to be read, from left to right.
Download the 1411.5226.printtable.zip file and unzip it.
To use the script, create a new project or use an existing BDLT project.
Add a script with the contents of the printtable.bdf script.
Place the index.html file at C:\ or whatever you want. Please make sure the BrowserNavigate() function points to the correct location of your index.html file.
The script uses print statements to output the values found in the table to the Output Window under the Monitor tab in your Silk Performer Workbench, as displayed below: