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--4601)



Object Required Error - sharmi84 - 03-24-2011

Hi Ankur,

My task is to enable a checkbox of a required link. I've written the below code for accomplishing it.

It worked well initially. Suddenly when i tried executing today it throws error at "workspace_chkbox.Click" and says "Object Required".

Im confused on this coz it worked well before. Kindly help me on this.
The code below is for you reference



Code:
Dim workspace_chkbox
col_cnt = Browser("NPDM").Page("ENOVIA").Frame("MainFrame").WebTable("WorkspaceTable").GetROProperty("cols")
row_cnt = Browser("NPDM").Page("ENOVIA").Frame("MainFrame").WebTable("WorkspaceTable").RowCount
For i = 1 to row_cnt
    Workspace_Check= Browser("NPDM").Page("ENOVIA").Frame("MainFrame").WebTable("WorkspaceTable").GetCellData(i,col_cnt)
    If trim(Workspace_Name) = trim(Workspace_Check)  Then
                Set workspace_chkbox = Browser("NPDM").Page("ENOVIA").Frame("MainFrame").WebTable("WorkspaceTable").childitem(i,1,"WebCheckBox",0)
                [b]workspace_chkbox.Click[/b]        Exit For
    End If
Next

Thanks in Advance!

Sharmila


RE: Object Required Error - manishbhalshankar - 03-24-2011

Hi Sharmila,

Always use "Option Explicit" as the first line of your code. This will throw error if there is any typo in variable name or if a variable is not defined. In your code you have used: Workspace_Check and workspace_chkbox. If Option Explicit is not there then both the variables are considered as one and the same.

Check if the position of webcheckbox has changed in your application.


RE: Object Required Error - basanth27 - 03-24-2011

Manish -
That is not correct. Workspace_check and workspace_chkbox are different variables.
Option Explicit is a good suggestion.

Sharmila -
The issue is with regards to either a shift in the location of the object or index. One of the ways i can suggest is to use On Error Resume next.
Try this code,
Code:
Dim workspace_chkbox
On Error Resume Next
col_cnt = Browser("NPDM").Page("ENOVIA").Frame("MainFrame").WebTable("WorkspaceTable").GetROProperty("cols")
row_cnt = Browser("NPDM").Page("ENOVIA").Frame("MainFrame").WebTable("WorkspaceTable").RowCount
For i = 1 to row_cnt
Workspace_Check= Browser("NPDM").Page("ENOVIA").Frame("MainFrame").WebTable("WorkspaceTable").GetCellData(i,col_cnt)
If trim(Workspace_Name) = trim(Workspace_Check) Then
Set workspace_chkbox = Browser("NPDM").Page("ENOVIA").Frame("MainFrame").WebTable("WorkspaceTable").childitem(i,1,"WebCheckBox",0)
workspace_chkbox.Click
msgbox Err.Number & " Error Number"
Msgbox Err.Description & " Error Description"
Exit For
End If
Next



RE: Object Required Error - sharmi84 - 03-24-2011

Hi Manish,

I tried option explicit and now i find it works. Thank you so much for your suggestion

Sharmila