Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to select item from weblist?
#1
Solved: 11 Years, 4 Months ago
Hi,

I need to select a time from a calendar pop up, the time is displayed in a list. i have recorded the time by clicking the list but while running, the time is not selected from the list.

code:
Code:
Browser("Calendar").Page("Calendar").WebList("Hour").Select "8"
Browser("Calendar").Page("Calendar").WebList("Minute").Select "30"

Can anyone help me

Thanks in advance
Reply
#2
Solved: 11 Years, 4 Months ago
Hi,

You can refer the items using index property to fetch from a list.

From what you have given, I understand that hours and minutes drop down are separte and will always present values from 0-12/24 and 0-60 respectively.

E.g.
Code:
Browser("Calendar").Page("Calendar").WebList("Hour").Select "#3"

Note - Indexing starts from 0 so the above line will fetch the 4th value from the drop down list. But if the values in the drop down change then irrespective of the value you want, it will always give you the value in the 4th position of the drop down.

I hope this helps.
Reply
#3
Solved: 11 Years, 4 Months ago
Intresting. It should select the value based on what you supply. The above statement looks absolutely fine to me.

Does it throw any error message ?

can you try ,
code:
Code:
Browser("Calendar").Page("Calendar").WebList("Hour").Highlight
Browser("Calendar").Page("Calendar").WebList("Hour").Select "8"
Or you can overwrite QTP's select function by using your own select,

1. Grab all the items in the list by using the value property.
2. Split the values if they are semicolon separated.
3. Compare the value which you need to select vs the value in the split array.
4. Select based on the index.

this is a foolproof method because the index does not get hardcoded here. so, inspite of the shift in the value location it will still select the right one.
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  WEBLIST shayk1985 3 5,618 05-17-2018, 11:49 AM
Last Post: Ankur
  Cannot identify the specified item Beginner 0 2,487 06-22-2017, 04:55 PM
Last Post: Beginner
  [UFT] SwfObject as Toolbar: select item without coordinates felino 0 3,305 11-27-2015, 03:09 PM
Last Post: felino
  WinListView set item command Shahino007 0 2,652 10-06-2015, 03:57 PM
Last Post: Shahino007
  Weblist selection diya 11 21,376 06-16-2015, 08:27 PM
Last Post: rajpradeep32

Forum Jump:


Users browsing this thread: 2 Guest(s)