Micro Focus QTP (UFT) Forums
object required 'A' 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 'A' error (/Thread-object-required-A-error)



object required 'A' error - sia sharma - 08-21-2012

hi all
i m getting this error while running this code


thanks
sia


Code:
A = Browser("Justdial").Page("Justdial").WebElement(DataTable("categories", dtGlobalSheet)).GetROProperty("innertext")
msgbox A
If A.Exist Then
    Reporter.ReportEvent micPass,"pass","category found 1"
    else
    Browser("qpr").Page("qpr").Link("2").Click
        If A.Exist Then
            Reporter.ReportEvent micPass,"pass","category found 2"
            else
            Browser("qpr").Page("qpr").Link("3").Click
                    If A.Exist Then
                        Reporter.ReportEvent micPass,"pass","category found 3"
                        else
                        Browser("qpr").Page("qpr").Link("4").Click
                            If A.Exist Then
                                Reporter.ReportEvent micPass,"pass","category found 4"
                                else
                                Browser("qpr").Page("qpr").Link("5").Click    
                                    If A.Exist Then
                                        Reporter.ReportEvent micPass,"pass","category found 5"
                                        else
                                        Reporter.ReportEvent micFail,"invalid","category not found"
                                    End If                                                        
                            End If
                    End If
            End If
End If



RE: object required 'A' error - Ankesh - 08-21-2012

@ Sia,

the below statement returns a string
Code:
A = Browser("Justdial").Page("Justdial").WebElement(DataTable("categories", dtGlobalSheet)).GetROProperty("innertext")

you can not check for the existance of the string using .Exist method. This can be used only for objects. Hence you are getting the error as object required for the statement.

If you want to check if the string found or not, you should use INstr function. Refere to qtp help.

Regards,
Ankesh


RE: object required 'A' error - sree.85 - 08-23-2012

replace the code with

if not isempty(a) then
....
....