Big news! The community will be moving to a new platform April 21. Read more.
Big news! The community will be moving to a new platform April 21. Read more.

Sample Code - How to print the contents of a table using a BDLT project

Sample Code - How to print the contents of a table using a BDLT project

Introduction

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:

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 #:
2 of 2
Last update:
‎2019-03-07 09:57
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.