Thread Rating:
  • 2 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How To Find Dropdown Object based on Values from the dropdown list
#1
Solved: 11 Years, 3 Months, 3 Weeks ago Sad 
Hi,

I'm having difficulty scripting for below situation...

I have a dropdown list, in the dropdown list I've values as below...
one
two
three
four
five

I want to find the dropdown object exists or not based on the dropdown list values as shown above. How to find the object? Please help!!

Regards,
Anil
Reply
#2
Solved: 11 Years, 3 Months, 3 Weeks ago
Please use getRoProperty("allitems") to achieve this. allitems is a property for a list object that holds all the drop down items seperated by a delimiter say ;

Reply
#3
Solved: 11 Years, 3 Months, 3 Weeks ago
Thanks Ravi for replying.
I tried this option getRoProperty("all items"), but my need is, not just to get all the items, I want to search one particular item from combo box, if that item exist then I want to perform an action else other action. I want to seach instead of getting items...

Please suggest

Thanks, Anil
Reply
#4
Solved: 11 Years, 3 Months, 3 Weeks ago
Hi Anil,
Yeah for us to acheive this, we may try as shown below
Code:
allitems=browser().page().WebList().getRoProperty("allitems")
IF instr(allitems,"one")<>0 Then  'where "one" is an item you are looking for
   'perform the action you want to
End IF

Regards,
Ravi


Reply
#5
Solved: 11 Years, 3 Months, 3 Weeks ago
Hi Ravi,

Thanks a lot for the help...
it is working... just did a small change as below
Code:
allitems = Browser("Browser").Page("Real Estate Enterprise").Frame("ContentFrame_2").WebList("cboPLC").GetROProperty("all items")

instead of page, gave the path till object as I'm looking for object property values.

Thanks once again!! Smile

Regards,
Anil
Reply
#6
Solved: 11 Years, 3 Months, 3 Weeks ago
Hi,

I am having a similar kind of issue as you are discussing. I want to search for an option in the drop down that has a specific string and select it.

Ex. If my drop down is having these options

100 Hyderabad
100 Secunderabad
200 Vijayawada
200 Tirupati
300 Chennai

And I want to look for the option that has this partial text "100" and select it. It can be any of the first two options. How do I achieve this using QTP? Please help.
Thanks.
Reply
#7
Solved: 11 Years, 3 Months, 3 Weeks ago
Hi Neetha,

Here is code for your Question
Code:
allitems = split(browser().page().WebList().getRoProperty("all items"), ";")

for each x in allitems
if instr(x, "100") > 0 Then
browser().page().WebList().select x
strFound = True
Exit For
next

if strFound = True Then
msgbox "I tem is listed in the list box and selected"
Else
msgbox "Item is not listed in the list box"
end if
Reply
#8
Solved: 11 Years, 3 Months, 3 Weeks ago
ExpectedResult="London"
'allitems=Window("Flight Reservation").WinComboBox("Fly From:").GetROProperty("all items:=DenverFrankfurtLondonLosAngelesParisPortlandSan FranciscoSeattleSydneyZurich")
Itemscount=Window("Flight Reservation").WinComboBox("Fly From:").GetROProperty("all items")
MsgBox Itemscount
result=Split(Itemscount,";")
For i = 0 To UBound(result) 
currentitem=Window("Flight Reservation").WinComboBox("Fly From:").GetItem(i)
MsgBox currentitem
If currentitem=ExpectedResult Then
    MsgBox "expected item exists in WebList"
else
MsgBox "expected item Not exists in WebList"
Window("Flight Reservation").WinComboBox("Fly From:").Select ExpectedResult
Exit for
End If
    
Next
Reply
#9
Solved: 11 Years, 3 Months, 3 Weeks ago
Other simple way is to provide the xpath till the option and then click.

Code:
Browser("Browser").Page("Page1").WebElement("xpath:=//selct[@id="your list box id"]/option[contains(.,'list item')]").click
Hope this is helpful.
Thanks,
SUpputuri
Reply
#10
Solved: 11 Years, 3 Months, 3 Weeks ago
allitems=browser().page().WebList().getRoProperty("allitems")
IF instr(allitems,"one")<>0 Then 'where "one" is an item you are looking for
'perform the action you want to
End IF
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  how to select value from google search box dropdown +QTP prajyot 0 2,897 06-28-2017, 06:30 PM
Last Post: prajyot
  Trying to create List box in excel sheet at Run time with values yes No JACKSPARROW 0 1,707 01-17-2017, 11:05 AM
Last Post: JACKSPARROW
  General Object Error(Find Object Error) akhandesh 1 3,597 02-24-2016, 01:05 PM
Last Post: sindhus
  Compare second web list value according to the first web list value roselin6 1 2,838 10-07-2015, 09:14 PM
Last Post: supputuri
  Problem selecting in a dropdown menu during playback. qemls29 9 13,029 07-28-2015, 05:44 PM
Last Post: Sharan

Forum Jump:


Users browsing this thread: 4 Guest(s)