Micro Focus QTP (UFT) Forums
Cannot identify the specified item of the regions object. - 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: Cannot identify the specified item of the regions object. (/Thread-Cannot-identify-the-specified-item-of-the-regions-object)



Cannot identify the specified item of the regions object. - Uma - 07-29-2011

Hi,
I have 2 dropdown listboxes called region and city/area.
It needs to select one region(Santa Clara) and one city/Area(Sunnyvale).So I put this in the for loop and I am storing the Items in the variable called itemname.
The regions value will get changed,so I used reg expression for this regions.
This is my code
Code:
Browser("MLSListings.com").Page("MLSListings.com").Link("ยป County/Area").Click
Browser("MLSListings.com").Page("MLSListings.com").WebList("regions").Check CheckPoint("regions")
ListSize=Browser("MLSListings.com").Page("MLSListings.com").WebList("regions").GetTOProperty("items count")
For i = 1 To ListSize-1
Itemname =Browser("MLSListings.com").Page("MLSListings.com").WebList("regions").GetItem(i+1)
Browser("MLSListings.com").Page("MLSListings.com").WebList("regions").Select Itemname
.................
If I run the script,I am getting the following error,
Cannot identify the specified item of the regions object.
Confirm that the specified item is included in the object's item collection.

Any Help?

Thank you,
Uma


RE: Cannot identify the specified item of the regions object. - rajpes - 07-29-2011

Code:
'loop counter problem!
For i = 1 To ListSize
Itemname =Browser("MLSListings.com").Page("MLSListings.com").WebList("regions").GetItem(i)


'by the way you can directly select items like this
For i = 0 To ListSize-1
Browser("MLSListings.com").Page("MLSListings.com").WebList("regions").select "#"&i



RE: Cannot identify the specified item of the regions object. - tdevick - 07-29-2011

One problem I see (but not the cause of your crash) is that in your loop, "i" starts at "1". Then you set "itemname" to ...GetItem(i+1), so the first element you get is element #2; item #1 gets ignored. Maybe that's by design.

It sound to me like it is getting a value via "GetItem(i+1)" that cannot be selected in the next line for some reason. I ran your code on our test web site on a couple of different dropdowns and it worked OK.

To help you find the error, try changing your code to work like this until you find the problem:

.................
Code:
For i = 1 To ListSize-1
Itemname =Browser("MLSListings.com").Page("MLSListings.com").WebList("regions").GetItem(i+1)
Err.Number=0
On Error Resume Next
Browser("MLSListings.com").Page("MLSListings.com").WebList("regions").Select Itemname
If Err.Number <> 0 Then
    x=1
End If
.................

and set a breakpoint on the line "x=1". When the debugger breaks on that line, you can examine "Itemname" and see what it is. It sounds like when this happens that the value for "Itemname" is not on the list for some reason.


RE: Cannot identify the specified item of the regions object. - Uma - 08-10-2011

Thank you,both of you for the detailed solution.It was very helpful.I gave On Error Resume Next Statement and used # in Global Data Table.
I gave my global data table values like this
(Previous Values
Region-Column Name
Row1-Santa Clara,
Row2-San Mateo)
Changed values(
Region-Column Name
Row1-#1
Row2-#2)
It worked.
[ REF:Mercury QuickTest Professional User's Guide > Appendixes > Troubleshooting QuickTest Tests > Run Error: Cannot identify item]
Thank you for your time.
Thank You
Uma



Thank you,for both of you for the detailed solution.
It was very help ful.
I gave On Error Resume next and used # in the Global datatable.

PreviousData:
Region-Column Name
Row1:Santa clara
Row2:San Mateo



Region-Column Name
Row1:#2
Row2:#3

[Ref:Mercury QuickTest Professional User's Guide > Appendixes > Troubleshooting QuickTest Tests >
Run Error: Cannot identify item]
Thans for you time
Thank you,
Uma