Reputation: 302
Thanks in Advance :) I can get the row count but not the column count using columncount method in uft 12.2. It simples throws an error at AccNoCol=AccNoTB.ColumnCount
Wrong number of arguments or invalid property assignment: 'AccNoTB.ColumnCount'. I know the column count is 8 here however they are dynamic & there is a risk to hard code the column count in script. Could you plz point out the correct? Thanks again
Set AccNoTB=browser("title:=.*").page("title:=.*").webtable("column names:=;Account No;Account Name;Billing City;Website;Phone;Assigned To;Action","cols:=8")
AccNoRow=AccNoTB.RowCount
AccNoCol=AccNoTB.ColumnCount
AccTBvalue=AccNoTB.GetCellData(AccNoRow,AccNoCol)
MsgBox AccTBvalue`
Upvotes: 1
Views: 1768
Reputation: 1
set a=Browser("OrangeHRM").Page("OrangeHRM_2").WebTable("micclass:=WebTable","html tag:=TABLE")
co=a.RowCount
MsgBox co
'set b=Browser("OrangeHRM").Page("OrangeHRM_2").WebTable("micclass:=WebTable","html tag:=TABLE")
col=b.ColumnCount
MsgBox col
Upvotes: -1
Reputation: 3784
Two simple ways to get Row and Column counts.
Note that I've removed "cols:=8"
from object description, assuming the WebTablt is getting identified by column names
.
Set AccNoTB=browser("title:=.*").page("title:=.*").webtable("column names:=;Account No;Account Name;Billing City;Website;Phone;Assigned To;Action")
Two ways to get Rows count
AccNoRow = AccNoTB.GetROProperty("rows") '<-- 1
AccNoRow = AccNoTB.RowCount '<-- 2
Two ways to get Column count
AccNoCol = AccNoTB.GetROProperty("cols") '<-- 1
iRow = 2
AccNoCol = AccNoTB.ColumnCount(iRow) '<-- 2 This way is useful when you have different columns in different rows.
Now lets take the example that @Motti have given. In this case we'll run a loop and get the column count.
Set AccNoTB=browser("title:=.*").page("title:=.*").webtable("column names:=;Account No;Account Name;Billing City;Website;Phone;Assigned To;Action")
AccNoRow = AccNoTB.RowCount
For i = 1 To AccNoRow
AccNoCol = AccNoTB.ColumnCount(i)
Print "Row " & i & " has " && " column/s."
Next
Output:
Row 1 has 1 column/s.
Row 2 has 2 column/s.
Row 3 has 3 column/s.
Upvotes: 0
Reputation: 114695
The column count of each row in the WebTable
can differ therefore ColumnCount
requires a parameter to specify to UFT which row's column count you're interested in.
A row can have
<table border=1>
<tr><td>One</td></tr>
<tr><td>or</td><td>two</td></tr>
<tr><td>or</td><td>even</td><td>more</td></tr>
</table>
Columns
Upvotes: 0