Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» New! Appium Desktop
Today at 3:51 pm by azharuddin

» Selenium WebDriver Integration
Tue Nov 21, 2017 1:06 pm by azharuddin

» how to connect DB in selenium webriver
Fri Oct 06, 2017 4:09 pm by anbarasi

» How find any text in browser screen and click on it?
Thu Oct 05, 2017 2:02 pm by sandeepkommineni

» Selenium Webdriver
Tue Oct 03, 2017 1:35 pm by PiyushBiswas

» GRID setup tutorial.
Wed Sep 27, 2017 4:29 pm by johnyapp

» Drag & Drop Between Windows Using Selenium Driver
Wed Sep 27, 2017 2:10 pm by 26rondel

» Check if window is closed / verify input
Sat Sep 23, 2017 10:21 pm by brainstir

» How to work on pages with AJAX in selenium?
Mon Sep 18, 2017 6:08 pm by azharuddin

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
avatar
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


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