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: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Object Required Error (/Thread-Object-Required-Error--6439)



Object Required Error - branjitk - 06-06-2012

Hi
I am having the problem for Object Required Error.
I want to increment the index property for WebElement,For index property "0" it is doing good. While i am increment the index property it says object required. The below code is used for this.

Code:
l=0
Do while Browser("Browser").Page("ShipmentLink - Sailing_2").WebTable("Seq_2").ChildItem(a_rows, a_cols, "WebElement", l).Exist(5)
Set objChildItem = Browser("Browser").Page("ShipmentLink - Sailing_2").WebTable("Seq_2").ChildItem(a_rows, a_cols, "WebElement",l)
objChildItem.Click
l = l+1
Loop

Please Can anyone tell me the solution for this.

Regards,
Ranjit Kumar.B


RE: Object Required Error - anil2u - 06-06-2012

Hi,

If u are having only one webelement in the cell, don't iterate the index property in childitem, as it will search for that particular indexed webelement in that cell and not finding any, it will return an error.

Just put it as 0 & try.

Let me know if any info. is needed.

Regards


RE: Object Required Error - branjitk - 06-07-2012

Hi anil,

Thankyou for your reply,
For "0" it is working,But in my webtable 5 rows and for every row one element is there.i want to click on each webElement in each row.

Thanks & Regards,
Ranjit Kumar.B


RE: Object Required Error - sshukla12 - 06-07-2012

Hi,
U have 5 rows in ur webtable , so intead of increasing the index number try to increment the row and check if same coulmn is used

try something like this:

Code:
Do while Browser("Browser").Page("ShipmentLink - Sailing_2").WebTable("Seq_2").ChildItem(I, a_cols, "WebElement", 0).Exist(5)
Set objChildItem = Browser("Browser").Page("ShipmentLink - Sailing_2").WebTable("Seq_2").ChildItem(I, a_cols, "WebElement",0)
objChildItem.Click
l = l+1
Loop


I am assuming that weblement is present in same column no. for each row.U can increment the index when more than one item present in same cell.

Let me know for more clarifications

Regards,
Sankalp


RE: Object Required Error - branjitk - 06-07-2012

Hi Sankalp,
I am sending the Screenshot of my web table, in that last column i circled it. For that link i am trying to put the Index property. But it is not working.

I am doing following code for row and column count and also the cell data.
Code:
If Browser("Browser").Page("ShipmentLink - Sailing_2").WebTable("Seq_2").Exist(5) Then
a_rows = Browser("Browser").Page("ShipmentLink - Sailing_2").WebTable("Seq_2").GetROProperty("rows")
a_cols = Browser("Browser").Page("ShipmentLink - Sailing_2").WebTable("Seq_2").GetROProperty("cols")
l = 0
  For i = 1 to a_rows
     For j = 1 to a_cols
     If Browser( "Browser").Page("ShipmentLink - Sailing_2").WebTable("Seq_2").Exist(20)Then
     a_celldata = Browser("Browser").Page("ShipmentLink - Sailing_2").WebTable("Seq_2").GetCellData(i,j)
                            End If
         If a_celldata = "Details" Then
Do while Browser("Browser").Page("ShipmentLink - Sailing_2").WebTable("Seq_2").ChildItem(a_rows, a_cols, "WebElement", l).Exist(5)
Set objChildItem = Browser("Browser").Page("ShipmentLink - Sailing_2").WebTable("Seq_2").ChildItem(a_rows, a_cols, "WebElement",l)
objChildItem.Click
l = l+1
Loop
Next
Next
End If



RE: Object Required Error - ssvali - 06-07-2012

Hi ,
By looking at ur screen shot it looks like column remains same.
Try below script and let us know the result

Code:
If  Browser("Browser").Page("ShipmentLink - Sailing_2").WebTable("Seq_2").Exist(5) Then

    a_rows = Browser("Browser").Page("ShipmentLink - Sailing_2").WebTable("Seq_2").GetROProperty("rows")

        For r = 1 to a_rows

            a_celldata = Browser("Browser").Page("ShipmentLink - Sailing_2").WebTable("Seq_2").GetCellData(i,j)

                If a_celldata = "Details"  Then

                    Set objChildItem = Browser("Browser").Page("ShipmentLink - Sailing_2").WebTable("Seq_2").ChildItem(r, 11, "WebElement",l)
                    objChildItem.Click

                    
                End If

        Next
Else

    Msgbox "Required Table does not exists"
    
End If



RE: Object Required Error - branjitk - 06-07-2012

Hi,
Thank you for your reply,

The code is perfectly working.
Thanks alot.

Regards,
Ranjit Kumar.B