Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

how to identify element using xpath having same class names?

View previous topic View next topic Go down

how to identify element using xpath having same class names?

Post by balakrishna on Tue Apr 22, 2014 1:29 am

Example: "html/body/form/table[3]/tbody/tr/td[2]/input"

In the above example td[2] has two same class names as mybutton1 for two different buttons ( save and Next). Can any one help me how can i identify the these buttons? I tried it with above example and it is picking up Save button.

balakrishna

Posts : 2
Join date : 2014-04-03

Back to top Go down

Re: how to identify element using xpath having same class names?

Post by Adviser on Tue Jun 24, 2014 6:00 pm

hi,
use index value instead of class name 
html/body/form/table[3]/tbody/tr/td[2]/input[1] for save
html/body/form/table[3]/tbody/tr/td[2]/input[2] for cancel

_________________
Spread Your Knowledge About Selenium Tool.

Administrator
Email: selenium.discussion.thread@live.com
Forum: http://seleniumforum.forumotion.net

Adviser
------------------------
------------------------

Posts : 379
Join date : 2009-07-30
Location : India

http://seleniumforum.forumotion.net

Back to top Go down

Re: how to identify element using xpath having same class names?

Post by ravindarreddy.nalla on Sat Jul 19, 2014 12:51 am

Hi BalaKrishna.

Don't use indexes, Object identification failed if another object is added in between objects. Try below code if not works let me know the same.

Code:
Driver.findElements(By.xpath("//input[text()='Save']"));
Driver.findElements(By.xpath("//input[text()='Cancel']"));

ravindarreddy.nalla

Posts : 5
Join date : 2014-07-19

Back to top Go down

Re: how to identify element using xpath having same class names?

Post by mail2prassad on Tue Jul 22, 2014 4:16 pm

I think it is
Code:
driver.findElement

rather than
Code:
driver.findElements

mail2prassad
Amateur
Amateur

Posts : 41
Join date : 2013-06-05

Back to top Go down

Re: how to identify element using xpath having same class names?

Post by ravindarreddy.nalla on Wed Jul 23, 2014 1:44 pm

Yes Prassad. It is webelement we need to use driver.findElement only

ravindarreddy.nalla

Posts : 5
Join date : 2014-07-19

Back to top Go down

Re: how to identify element using xpath having same class names?

Post by nabhanya.varma on Sat Sep 13, 2014 5:25 pm

hi, try using relative xpath instead of using absolute xpath.
 Relative xpath is one where the path starts from the node of your choise - it doesn't need to start from the root node.
It starts with Double forward slash(//)
For more.. Please visit
http://www.seleniumeasy.com/selenium-tutorials/xpath-tutorial-for-selenium

nabhanya.varma
Active particpant
Active particpant

Posts : 13
Join date : 2014-03-02

Back to top Go down

Re: how to identify element using xpath having same class names?

Post by Sponsored content Today at 1:06 am


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum