Sam_Chn Absent Member.
Absent Member.
382 views

How to count columns of a table displayed using 4Test ?

Hi,

 

I need help to count number of columns in a table displayed using 4Test. Please provide if there are any ideas.

 

Thanks and Regards,

Samuel M.

0 Likes
3 Replies
Highlighted
Micro Focus Frequent Contributor
Micro Focus Frequent Contributor

RE: How to count columns of a table displayed using 4Test ?

Hi Samuel,

Can you please clarify what type of table you are testing against, for example is it a HTML table or is it created using another technology?

Thanks,
John
0 Likes
Sam_Chn Absent Member.
Absent Member.

RE: How to count columns of a table displayed using 4Test ?

Hi John,

Thank you for your response. I am developing 4Test scripts for a web application. The table for which the column count required, is pulled from COGNOS and displayed in html page. I tried to use getproperty function for the property - "ctx" for the count. But that property is not supported in Mozilla Browser. Please provide your suggestions.

Thanks and Regards,
Samuel M.
0 Likes
Micro Focus Expert
Micro Focus Expert

RE: How to count columns of a table displayed using 4Test ?

Hi Samuel,

For a standard DomTable object, Silk Test provides the GetColumnCount method for retrieving the number of columns. For example, to retrieve the number of columns for the DomTable on the following page:

www.w3schools.com/.../tryit.asp

The code would be:

[ ] print(FindDomTable("//BrowserApplication//BrowserWindow//IFRAME[@id='iframeResult']//TABLE").GetColumnCount())


If the Table/Grid in question is generated by a JavaScript library, it is possible that you may need to implement your own solution for counting the columns. For example, each column may use the same css class. If that is the case, you could simply find all the elements that have this css class and then count the number of elements returned.

List of Window lwCols = wMyTable.FindAll("//*[@class='column-class']")
ListCount(lwCols)


-Robert
0 Likes
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.