if two links having the same name how can we click on second link

995 views
Skip to first unread message

S.T.Hussain

unread,
Dec 27, 2010, 7:32:18 AM12/27/10
to Selenium Users
I have two links with same name "apple" and two buttons with same
name"click here"

i want to click on second link or first button. how can i do that

Smruti Ranjan Sahoo

unread,
Dec 28, 2010, 12:12:48 PM12/28/10
to seleniu...@googlegroups.com
document.findElementsbyname() returns an array of all the elements having the same name.
In your case document.findElementsbyname("apple") returns and array containing both the links.
Now, document.findElementsbyname("apple")[0].click() clicks the first link
and document.findElementsbyname("apple")[1].click() clicks the second.

~Smruti


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.


Vinothkumar M

unread,
Dec 29, 2010, 12:54:46 AM12/29/10
to seleniu...@googlegroups.com
Hi Hussain,
 
Please find the below link,
 
 
May be it will help you.

Regards,
Vinodh.

farheen khan

unread,
Dec 29, 2010, 1:13:21 AM12/29/10
to seleniu...@googlegroups.com
Hi Hussain,

For 2nd link

selenium.clickAndWait("//a[@name='apple'][position()=2]");

For 1st button

selenium.click("//input[@type='button'][position()=1]");


This might help!!!

 
--

Farheen
http://seleniumready.blogspot.com/



Syed Hussain

unread,
Dec 29, 2010, 7:21:50 AM12/29/10
to seleniu...@googlegroups.com
This won't work. let take a example. i want to do the following task:
1. go to the website  www.yahoo.com
2. click on the link "Mail" to check my emails

any 1 plz help

farheen khan

unread,
Dec 30, 2010, 12:12:00 AM12/30/10
to seleniu...@googlegroups.com
Give an example...Wil give u the code

Farheen
http://seleniumready.blogspot.com/



farheen khan

unread,
Dec 30, 2010, 1:44:41 AM12/30/10
to seleniu...@googlegroups.com

Syed Hussain

unread,
Dec 30, 2010, 1:49:10 AM12/30/10
to seleniu...@googlegroups.com
Thanks a lot its working :) 

amrendra(AK) kumar

unread,
Dec 29, 2010, 7:29:52 AM12/29/10
to seleniu...@googlegroups.com
Try to use id of that link.
if in java
selenium.click("id");

On Wed, Dec 29, 2010 at 5:51 PM, Syed Hussain <sthus...@gmail.com> wrote:



--

Thanks and Regards,

Amrendra Kumar

QA Analyst, Nitor InfoTech Pvt. Ltd

501 - 502, Mayfair Towers, Shivaji Nagar, Wakadewadi,

Mumbai-Pune Highway, Pune-411005, India

Tel No: +91-20-41020202

Website: www.nitorinfotech.in

Brilliance @ Work

 


Reply all
Reply to author
Forward
0 new messages