Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Selecting a WebElement from a List of Web Elements
02-21-2012, 05:42 PM
Post: #1
Selecting a WebElement from a List of Web Elements

Hi All,
I am working on a scenario, where I need to select a particular item from a list of items in a Window. The I have written is below:

'Initializing a Flag
Valid=False
Set objShell=CreateObject("WScript.Shell")
'Looping the statement
Do Until Valid=True
'Itemname is the name of the WebElement I need to select
If(Brw(X).Pg(X).WebElement("html tag:=TD","innertext:="itemname,"outertext:="itemname,"index:=1").Exist (2))Then
Brw(X).Pg(X).WebElement("html tag:=TD","innertext:="itemname,"outertext:="itemname,"index:=1").Click
'The below statement will add the selected Item to the "Selected Items panel"
Brw(X).Pg(X).WebElement("class:=bi-button button.*","innertext:=>>","index:=1").Click
Valid=True
Else
'Here the Page down button will be pressed if the WebElement is not found in the visible.Just like a Scroll Down
objShell.SendKeys "{PGDN}"
Valid=False
Loop

The problem I face with the above code is that some times the incorrect item gets selected to the "Selected items window". If I dont use index I get "Object description matches more than one WebElement" error.

The incorrect item that gets selected is always just above or below the correct one. Most of the times code works properly, sometimes I got wrong things selected. eg: I need to select 'Delete' item whose innertext value is 'Delete'.

Delete a value
Delete
Delte by name

The aboce code selects, "Delete a value" or "Delete by name" instead of 'Delete' from the list.

Note: No html id available. Im working on a Web application that runs in IE8.

I hope someone could help me in fixing the codes
Find all posts by this user
Quote this message in a reply
02-22-2012, 09:54 PM
Post: #2
RE: Selecting a WebElement from a List of Web Elements
Just changed the order for selecing the items... It works fine..Very Wiered...
Find all posts by this user
Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Application and QTP freezes when recognizing/selecting Java Tab pora 4 1,419 01-10-2012 10:11 PM
Last Post: sunnyk8
  Problem selecting in a dropdown menu during playback. qemls29 7 1,039 11-29-2011 07:41 PM
Last Post: qemls29
Exclamation Problem selecting client certificate from IE dialog pumpkin 1 634 11-02-2011 08:55 AM
Last Post: Newbie2011
  QTP throws error on web elements when Descriptive programing used. nistalaramesh 20 5,851 10-11-2011 09:53 AM
Last Post: nistalaramesh
  Problem in selecting multiple items in the weblist vijay44 7 1,827 08-10-2011 06:22 PM
Last Post: gaveyom

Forum Jump:


User(s) browsing this thread: 1 Guest(s)