Example 1:
<body>
<h4>John Smith<input type=checkbox name="select" /></h4>
<body>
<h4>Anne Anderson<input type="checkbox" name="select" checked=true /></h4>
In QTP:
'Selecting John Smith
Browser("XPath").WebElement("xpath:=//h4[1]").Click
'Selecting Anne Anderson
Browser("XPath").WebElement("xpath:==/h4[contains(text(), 'Anne')]").Click)
Example 2:
XPath:
1. (//tr[@class='row2']/td[1])[2]
2. (//td[contains(text(),'Address')])[2]
In QTP:
1. Browser("XPath").WebElement("xpath:=(//tr[@class='row2']/td[1])[2]").Click
2. Browser("XPath").WebElement("xpath:=(//td[contains(text(),'Address')])[2]").Click
Example 4:
<table id='table1'>
<tr class='row1' id=BPT>
<td>View ID</td>
<td><input type='button' value='Button 1' class='btn_blue' id='btnfirst'></td>
</tr>
In QTP:
'Selecting Button 1
Browser("XPath").WebButton("xpath:=//td/input[@id='btnfirst']").Click
'Select Button 1
Browser("XPath").WebButton("xpath:=(//table[@id='table1']/*/*)[1]/*[2]/input").Click