Using Xpath in Selenium and Selenim RC 

The HTML Example Document

<div>
<ol>
<li>
<a title="Self Catering Apartments" href="http://www.ooo.coo">Self Catering Apartments</a>
</li>
<li>
<a title="Vacation Accommodation" href="http://www.ooo.coo">Vacation Accommodation</a>
</li>
<li>
<a title="Hotel" href="http://www.ooo.coo">Hotel</a>
</li>
<li>
<a title="Real Estate" href="http://www.ooo.coo">Real Estate</a>
</li>
</ol>
</div>

Uisng xpath to verify all the a tag elements
xpath = //div/ol/*/a[@href]
This will return all the a tag elements
In selenium you can use this command to verify if the elements have the href

<tr>
<td>verifyElementPresent</td>
<td>xpath = //div/ol/*/a[contains(@href, 'http://www')]</td>
<td></td>
</tr>

Submitted by Puddupakkam Pavandeep


Author: Pavandeep Puddupakkam on March 3, 2010
Category: Selenium IDE, Selenium RC, Software Testing
Tags: , ,
Google Webdriver Forum -The Online Community for Google Webdriver and Selenium RC Users and Professionals

Leave a Reply

Last articles