- balakrishna
- Posts : 2
Join date : 2014-04-03
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.
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.
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
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
- ravindarreddy.nalla
- Posts : 5
Join date : 2014-07-19
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.
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']"));
- mail2prassadAmateur
- Posts : 41
Join date : 2013-06-05
Re: how to identify element using xpath having same class names?
Tue Jul 22, 2014 4:16 pm
I think it is
rather than
- Code:
driver.findElement
rather than
- Code:
driver.findElements
- ravindarreddy.nalla
- Posts : 5
Join date : 2014-07-19
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
- nabhanya.varmaActive particpant
- Posts : 13
Join date : 2014-03-02
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
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
Permissions in this forum:
You cannot reply to topics in this forum