<html>
<head>
<body>
<table>
<tr>
<td>first column</td>
<td>second column</td>
</tr>
<tr></tr>
</table>
</body>
The xpath expression for the first row second column is:
/html/body/table/tbody/tr/td[2]
I'd like to use selenium to get the value '2'.
In other words, what is the value for the first occurrence of text
"second column". I'm able to get selenium to recognize that element
but not return the value.
What exactly are you trying to achieve? If the test is to confirm that you
are looking at the second column you have already done that with the XPath
you have supplied.
--
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.
--
This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited.
If you have received this email in error please notify postm...@ardescosolutions.com
http://stackoverflow.com/questions/8448828/xpath-for-returning-the-column-index
> For more options, visit this group athttp://groups.google.com/group/selenium-users?hl=en.
>
> --
> This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited.
>
> If you have received this email in error please notify postmas...@ardescosolutions.com
Finding the number of children an element has is very easy:
List<WebElement> childrenOfAnElement = driver.findElements(By.id("myElement"));
int numberOfElements = childrenOfAnElement.size();
You need to keep in mind that if you are iterating through the elements using XPath as described in the accepted solution in the link the XPath’s will start at 0 so you need to decrement the size by one to make sure you don’t get a null pointer error.
Finding the number of children an element has is very easy:
List<WebElement> childrenOfAnElement = driver.findElements(By.id("myElement"));
int numberOfElements = childrenOfAnElement.size();
You need to keep in mind that if you are iterating through the elements using XPath as described in the accepted solution in the link the XPath’s will start at 0 so you need to decrement the size by one to make sure you don’t get a null pointer error.
From: seleniu...@googlegroups.com [mailto:seleniu...@googlegroups.com] On Behalf Of Hien Ngo
Sent: 12 December 2011 17:16
To: seleniu...@googlegroups.com