There's also a bug you should file on the page code below.

for proper HTML ID attributes are supposed to be unique within the
page, but you have many instances where the same ID appears multiple
times..   it would be OK if those were 'Name' attributes, which are
not supposed to be unique, but for "ID" there is only ever supposed to
be one instance of a given value (such as, in your case "Display
profile" etc..)  This is really really basic stuff and goes way way
back..  Frankly I'm surprised to see this kind of thing happen, it
indicates to me a developer who's never bothered to learn the
standards of the protocoll they are using for most of their work.

This can cause issues for things like Watir when you try to identify
by ID, because Watir expects the page to be valid, standards complient
HTML, and when identifying elements by ID value will return the first
element found (regardless of type) that has the proper ID value.

As to the issue at hand. If you want to pick the 'edit' link according
to the username, you are likely going to have to figure out the
'employee id' value for the given employee first,  Fortunately you can
likely get that from the HREF for the 'display profile' link which
(only sometimes? ugh) has the username in it.  So you could get the
HREF for that link, parse it to figure out the 'employee id' value,
and then use that to craft up the expected HREF for the edit user
link.

it's hard to tell looking just at the html and not seeing it
rendered..  Potentially the other thing you might be able to do is
parse the table and find the row that has the name you want, and then
click on the cell in that row that would contain the edit user link
you need.

  (watircraft framework actually has some rather nifty stuff in it
that makes doing that kind of thing MUCH easier, allowing you to just
identify the row according to the contents of a given named column,
and then click on a given cell in that row. )

Stuff like this, where what you need is some potentially unknown
userid type value, but what you know is the user name, can be a bit of
a challenge.  The key is understanding the relationship on the page
(say within a row on a table) between the known value, and the
unknown, and use that to either take the action you want, or get the
value needed to take the action you want.   (uh  if that made any
sense.. hope I phrased that in a way that's not confusing)

On May 27, 11:22 pm, Swap <swapnal.sa...@gmail.com> wrote:
> I am in learning stage of Watir. I want to write the code in watir to
> click the particula  'Edit user' link.
>
> Please reply me.
>
> <table border="0" cellspacing="10" cellpadding="5">
>                         <tr>
>                                 <td colspan="5"><font class="star">
>                                 </font></td>
>                         </tr>
>                         <tr>
>                         <th>&nbsp;</th> <th>First name</th> <th>Last 
> name</th>                          <th>User
> name</th><th>Role</th><th>Allocated file quota</th>                           
>     <th>Occupied
> file quota</th><th>&nbsp;</th><th>&nbsp;</th>
>                         </tr>
>                         <tr>
>                 <td></td>
> <td><a id="Display profile" href="AppControl?pg=ListUsers&ret=Display
> profile&employee id=2">a</a></td>
>                                 <td>a</td>
>                                 <td>a</td>
>                                 <td>Group admin</td><td>10 MB.</td><td>3.3 
> KB.</td>
>                                 <td><a id="Edit user"        
> href="AppControl?pg=ListUsers&ret=Edit
> user&employee id=2">Edit    user</a></td>
>                                 <td><a id="Edit 
> profile"href="AppControl?pg=ListUsers&ret=Edit
> profile&employee id=2">Edit profile</a></td>
>                                 <td><a id="Delete 
> href='javascript:confirmDelete("AppControl?
> pg=ListUsers&ret=Delete user&employee id=2")'>Delete</a></td>
>
>                                 <td colspan="2"><a 
> href="AppControl?pg=ListUsers&ret=view
> gallery&employee id=2" id="view_gallery_link">View gallery</a></td>
>
>                         </tr>
>
>                         <tr>
>                         <td></td>
>                         <td><a id="Display profile"
>                                         
> href="AppControl?pg=ListUsers&ret=Display profile&employee
> id=1">admin</a></td>
>                                 <td>admin</td>
>
>                                 <td>admin</td>
>
>                                 <td>Admin</td>
>                                 <td>90 MB.</td>
>                                 <td>0.0 KB.</td>
>
>                                 <td><a id="Edit user"
>                                         
> href="AppControl?pg=ListUsers&ret=Edit user&employee id=1">Edit
>                                 user</a></td>
>                                 <td><a id="Edit profile"
>                                         
> href="AppControl?pg=ListUsers&ret=Edit profile&employee
> id=1">Edit
>                                 profile</a></td>
>                                 <td><a id="Delete"
>                                         
> href='javascript:confirmDelete("AppControl?
> pg=ListUsers&ret=Delete user&employee id=1")'>Delete</a></td>
>
>                                         <td><a id="Edit user" 
> href="AppControl?
> pg=ListUsers&ret=messagebox&employee id=1">Mailbox</a></td>
>
>                                 <td colspan="2"><a 
> href="AppControl?pg=ListUsers&ret=edit gallery"
> id="edit_gallery_link">Edit gallery</a></td>
>
>                                 <td colspan="2"><a 
> href="AppControl?pg=ListUsers&ret=view
> gallery&employee id=1" id="view_gallery_link">View gallery</a></td>
>
>                         </tr>
>
>                         <tr>
>
>                                 <td><input type="checkbox" name="employee_id" 
> id="employee_id"
> value="4"/></td>
>
>                                 <td><a id="Display profile"
>                                         
> href="AppControl?pg=ListUsers&ret=Display profile&employee
> id=4">b</a></td>
>                                 <td>b</td>
>
>                                 <td>b</td>
>
>                                 <td>Manager</td>
>                                 <td>10 MB.</td>
>                                 <td>0.0 KB.</td>
>
>                                 <td><a id="Edit user"
>                                         
> href="AppControl?pg=ListUsers&ret=Edit user&employee id=4">Edit
>                                 user</a></td>
>                                 <td><a id="Edit profile"
>                                         
> href="AppControl?pg=ListUsers&ret=Edit profile&employee
> id=4">Edit
>                                 profile</a></td>
>                                 <td><a id="Delete"
>                                         
> href='javascript:confirmDelete("AppControl?
> pg=ListUsers&ret=Delete user&employee id=4")'>Delete</a></td>
>
>                                 <td colspan="2"><a 
> href="AppControl?pg=ListUsers&ret=view
> gallery&employee id=4" id="view_gallery_link">View gallery</a></td>
>
>                         </tr>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To post to this group, send email to watir-general@googlegroups.com
Before posting, please read the following guidelines: 
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to 
watir-general-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/watir-general
-~----------~----~----~----~------~----~------~--~---

Reply via email to