Selenium Forum: Functional And Regression Testing Tool.
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
Display results as :
Advanced Search
Latest topics
AEM Training | Free Online DemoWed Apr 21, 2021 5:45 pmazharuddin
c# PageFactory - issue initializing elementsFri Nov 01, 2019 8:40 pmthegoatboy
Selenium making automatic connection to random urlsMon Jul 08, 2019 12:58 pmrepairtechsolutions1
How can we design the custom framework in Selenium RCMon Jun 24, 2019 2:26 pmrandybonnettes
What are the new features in Selenium 3.0Tue Jun 18, 2019 5:37 pmpappyvicky
What are you using Selenium for? Fri Apr 12, 2019 3:52 amzhl
LIMITATIONS OF SELENIUMWed Apr 10, 2019 11:23 amswara
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Go down
avatar
balakrishna
Posts : 2
Join date : 2014-04-03

how to identify element using xpath having same class names? Empty how to identify element using xpath having same class names?

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.
Advisor
Advisor
------------------------
------------------------
Posts : 387
Join date : 2009-07-30
Location : India
https://seleniumforum.forumotion.net

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

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
avatar
ravindarreddy.nalla
Posts : 5
Join date : 2014-07-19

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

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']"));
avatar
mail2prassad
Amateur
Amateur
Posts : 41
Join date : 2013-06-05

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

Tue Jul 22, 2014 4:16 pm
I think it is
Code:
driver.findElement

rather than
Code:
driver.findElements
avatar
ravindarreddy.nalla
Posts : 5
Join date : 2014-07-19

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

Wed Jul 23, 2014 1:44 pm
Yes Prassad. It is webelement we need to use driver.findElement only
avatar
nabhanya.varma
Active particpant
Active particpant
Posts : 13
Join date : 2014-03-02

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

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
Sponsored content

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

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