Search code examples
vbscriptqtphp-uft

QTP UFT How to find a row number and column number? Angular JS


When I spy the table it shows just browser - Page - WebElement and also UI is developed in Angular JS.

I there any way to find row number and column number? By the way I am using UFT/QTP

enter image description here

enter image description here


Solution

  • From the source-code's image which you have attached, it is quite evident that the webElement corresponding to the rows have class = "ui-grid-row ng-scope". So, you can make use of descriptive programming. I assume that you already have added the object Browser(...).Page(...) to your OR.

    Set rowDesc = Description.Create
    rowDesc("Class Name").value = "WebElement"
    rowDesc("Class").value = "ui-grid-row ng-scope"
    Set objRows = Browser(...).Page(...).ChildObjects(rowDesc)
    rowCount = objRows.Count                             'This variable should now contain the total number of rows"
    

    Now, this is just an idea which you can give a try. If it works for you, you can further enhance it to get the column count. If there is no way you can get the column count, then you can get the total cell count using the same method. In that case, you just need to change the value of property "class" to the one mentioned in the Object Spy Image("ui-grid-cell-contents ng-binding ng-scope"). Now you have Row Count and Cell Count. To get the column count, you can divide cell count by row count.(Again, this will give you correct answer ONLY IF there are same number of columns for each of tbe rows).