Micro Focus QTP (UFT) Forums

Full Version: object required Error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi All,
I'm getting Object Required error for the below mentioned code
Code:
For i = 1 to row_cnt
WorkspaceName = Browser("").Page("").Frame("").WebTable("").GetCellData(i,col_cnt)
    If trim(WorkspaceName) = trim(Workspace) Then
        Set Workspace_Chk = Browser("").Page("").Frame("").WebTable("").ChildItem(i,1,"WebCheckBox",0)
        Workspace_Chk.Click
      Exit For
End If
Next

I tried using Wait and object.INIT too but the problem still exist. I have declared the Varible and used Option Explict also in the begining. I'm using QTP 9.5

Thanks in advance for help
Lokesh
At which instance are you getting the error? Is it validating the If clause?
I see two potential problems, without knowing exactly where it's blowing up as Basanth pointed out.

Our web tables aren't always consistent. i.e., just because row 1 has 6 columns that doesn't mean that row 5 also has 6 columns. I don't think HTML requires you to have the same number of <TD> tags in each row of a table. If table(row,col_cnt) doesn't exist, you'll get an error on the line that does "Trim(Workspace)". I think (but can't remember off the top of my head) that calling CellData(x,y) where x or y is out-of-bounds will result in a QTP error.

The other thing I see that could be a problem is if "Browser("").Page("").Frame("").WebTable("").ChildItem(i,1,"WebCheckBox",0)" doesn't exist. Then you'll get a null reference for "Workspace_Chk". In the next line, when you try to use "Workspace_Chk", you'll get an error. I suggest you do something like "if IsNull(Workspace_Chk) then" and log some error or exit the test.