Micro Focus QTP (UFT) Forums
object required Error - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: object required Error (/Thread-object-required-Error--4651)



object required Error - lokesh.vinu@gmail.com - 04-04-2011

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


RE: object required Error - basanth27 - 04-05-2011

At which instance are you getting the error? Is it validating the If clause?


RE: object required Error - tdevick - 04-05-2011

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.