1

I am attempting to pull a value and a header (string) from a website, but unable to find the element using selenium.

My Code
I used Firebug to get the XPath and this is what it determined:

//*[@id="DimensionForm"]/p[1]/table/tbody/tr[3]/td[3]

Code

Dim Right as double
Dim Marker as string

Marker = selenium.findElementByXPath("//*[@id="DimensionForm"]/p[1]/table/tbody/tr[2]/td[3]").getAttribute("value")
Right = selenium.findElementByXPath("//*[@id="DimensionForm"]/p[1]/table/tbody/tr[3]/td[3]").getAttribute("value")

HTML CODE

<form  id="DimensionForm" name="validate" action="Dimension" method="post">
<div style="margin-top: 7px"></div>
<p><table width="100%" cellspacing="0" border="0" cellpadding="0" class="element">
<tr>
<td>&nbsp;</td><td class="formtitlenobg" colspan="6" align='right'>
AREA DIMENSIONS&nbsp; &nbsp; &nbsp; (AREA&nbsp;A) <span class='quote'> &nbsp; Front</span> 25.24</td>
</tr>
<tr align="right">
<td class="tablerowlightgreen" width=10>&nbsp;</td>
<th class="formtitle"  width=250 align="left">Property</th>
<th class="formtitle" width=50>Check</th>         <th class="formtitle" width=75>Front</th>
<th class="formtitle" width=75>Center</th><th class="formtitle" width=75>Left</th>
<th class="formtitle" width=120>Right</th>
<th class="formtitle" width=100>Total</th>
<td class="tablerow" width=50>&nbsp;</td>
<td class="tablerow">&nbsp;</td>
</tr>
<tr align="right" nowrap>
<td>&nbsp;</td>
<td class="table" align="left"><strong>
Property&nbsp;O</strong></td>
<td class="table">+</td>
<td class="table">10</td>
<td class="table">12</td>
<td class="table"><strong>12</strong></td>
<td class="table"><strong><font class="front">
100</font></strong></td>
<td class="table">120</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table></td>
</tr></table>
2
  • What's happening when you try your code? Nothing, or an exception? If it is an exception, can you edit your question and add the exception? Commented Oct 8, 2014 at 18:43
  • Seems that in the end of your html you have extra </td></tr></table>, and you are missing </p></form> Commented Oct 9, 2014 at 5:17

1 Answer 1

1

You have incorrectly nested quotes:

selenium.findElementByXPath("//*[@id="DimensionForm"]/p[1]/table/tbody/tr[2]/td[3]")

Perhaps you meant:

selenium.findElementByXPath("//*[@id='DimensionForm']/p[1]/table//tr[2]/td[3]")

Note the single-quotes in the second line!

Sign up to request clarification or add additional context in comments.

2 Comments

I had tried that, it still did not work. Thanks for the note though.
Drop the "tbody", as some browser will not render that element.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.