Sunday, September 5, 2010

Locator for cell containing nbsp in Selenium RC

If you want to point to a table cell containing a   (non breaking space) character then you must use the unicode equivalent of nbsp i.e \u00a0 in your locator. Interestingly this is required only in Selenium RC. A simple space would suffice if you were to achieve this in Selenium IDE. Below is the sample HTML code that has the table with the cell containing the nbsp and the selenium RC instruction to highlight that cell.

<table border="1">
<tr>
<td>abcd&nbsp;efgh</td>
<td>abcdefgh</td>
</tr></table>



selenium.highlight("//td[text()='abcd\u00a0efgh']");