+1 vote

How to get the total column number based on a certain row index in HTML

this is how to get the total row of a table :

totalRow =Window("Window").HTMLTable("HTMLTable").Property("Number of rows") println totalRow

In this HTML table, If I want the total column number of the first row, and I don`t know anything about the info of that row.

How to make that happen?
I know if you want find one certain column based on the the row Index, and you know the column info, then you can use

findColumnbyRow(1,"prop name","expected Value"..)

but in this case, I don`t know the property name, and I don`t want to find just one column.

I want to know the total column number of the row on the HTML,  can I make that happen?

asked Jan 6, 2016 in QA Wizard Pro by Leo

1 Answer

+1 vote
Best answer

XPath can do this. First we'll get the XPath of the table and add on the necessary extras. Alternatively, you could populate the repository and interact with the first row to get its XPath.

tableXPath = Window("Window").HTMLTable("HTMLTable").Property("Element Path")

firstRowXPath = tableXPath + "/tbody[1]/tr[1]"

cellCountXPath= "count(" + firstRowXPath + "/td)" ' http://www.w3.org/TR/xpath/#function-count

xpathResults = Browser("Window").PerformXPathQuery(cellCountXPath)

' PerformXPathQuery returns an array, our answer will be the first element
columnCount = xpathResults(1)
answered Jan 6, 2016 by Todd (520 points)
edited Jan 6, 2016 by SeapineAdmin
248 questions
262 answers
2,047 users