Micro Focus QTP (UFT) Forums
Unable to select items from WebLists - 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 Others (https://www.learnqtp.com/forums/Forum-UFT-QTP-Others)
+--- Thread: Unable to select items from WebLists (/Thread-Unable-to-select-items-from-WebLists)



Unable to select items from WebLists - CosmaShiva - 07-19-2012

Howdy,
I am automating a Web based app.
I have many WebLists.
When each WebList is clicked a list of elements is displayed.
However...weblist().Select() does not work.
Select returns an error that the required element canot be located.
QTP (including Object Spy) can only see the currently displayed element.
AllItems for the WebList does not include all the elements - only the one currently displayed.
When recording I can display the list of elements and use the down key to navigate to the required element - but the resulting code still shows the action as a SELECT.
Can anyone assist me with a way to access the dropdown element even though QTP does not recognise them.
Cheers and thanks,
Simon.


RE: Unable to select items from WebLists - K Gaurav Varshney - 07-19-2012

Hi,

Can you pls provide the snap shot of your screen u are working on and object spy.

Regards,
K


RE: Unable to select items from WebLists - CosmaShiva - 07-19-2012

Screenshots attached
hope this assists - thanks for your time
Simon


RE: Unable to select items from WebLists - Ankesh - 07-19-2012

Can you just use the below function to see if this is working for you.


Code:
Function SelectWebListValue(strValue, strObjectName)

'Get the total no of items in that dropdown
intItemsCount=Browser("").Page("").Frame("").WebList(strObjectName).GetROProperty("items count")
'Browser("").Page("").Frame("").WebList(strObjectName).Highlight
For intIndex = 1 To intItemsCount
    strTextFrmAppl=Browser("").Page("").Frame("").WebList(strObjectName).GetItem(intIndex)
    
    If strTextFrmAppl= strValue Then
        Browser("").Page("").Frame("").WebList(strObjectName).Select strValue
        Reporter.ReportEvent micPass,"Weblist selection","Given value ("& strValue &") selected"
        SelectWebListValue= True
        Exit For
    ElseIf intIndex=intItemsCount Then
        Reporter.ReportEvent micFail,"Weblist selection","Given value ("& strValue &") is not present"
        SelectWebListValue= False

    End If
Next

End Function

To call the function use the below code

Call SelectWebListValue("Your Value","WeblistObject")

Regards,
Ankesh

Remove frame from the function if it is not there in your object hierarchy.


RE: Unable to select items from WebLists - CosmaShiva - 07-20-2012

Howdy Ankesh,
Thanks for your response, but unfortunately this did not resolve my issue.
I've attached screen shots...

I feel that what I need to do is capture the object that displays the elements when I click on the dropdown button, and then interact with that object - just not sure how to get there...

Of course i may be barking up the wrong tree all together..

Cheers and thanks,

Simon.


RE: Unable to select items from WebLists - K Gaurav Varshney - 07-20-2012

Hi Simon,

Can you please tell me that in "Customer Type" weblist, the combo box and downArrow key associated with it are to diifferent components or the same, i.e. when you SPY, you are able to capture these two elements differently or not.
Do try again to check the above mentioned things.

Regards,
K


RE: Unable to select items from WebLists - Ankesh - 07-20-2012

did you debug the function? Are you able to get the values for strTextFrmAppl and intItemsCount variable? Chk it once and let me know the result.

Meanwhile you can also look a the properties of the weblist.

Browser("").Page("").WebList("").Object.<a list of properties will appear> '' Chk the properties and see if you could use any of them.


Regards,
Ankesh


RE: Unable to select items from WebLists - CosmaShiva - 07-23-2012

Howdy,

The combobox and button are seen as one control only.
Only one object is seen by QTP - ie: the WebList control.
It does not see a button and a separet edit control

Cheers,

Simon.

Howdy Ankesh,

Yes I did debug. The issue seems to be that "allitems" only has the item currently displayed. When you change the current value of the weblist "allitems' changes the the new element displayed - with no others.

i'm still thinking that I need to try to capture the popup list of element and work with that..but not sure how...

Cheers,

simon.


RE: Unable to select items from WebLists - Tarik Sheth - 07-23-2012

Hi,

Can you try some of the below.

1. Try focusing on the weblist and then .type method for 11, 12, 13 etc. if you know in advance which one to choose.
2. Focus on the web list object and try sendkeys method.

Let us know how it goes.