Reputation: 843
Below is my code.Am pasting my entire tag
<TR id="oldcontent" bgcolor="#D0D0D0">
<TD id="oldcontent">Foot-OM</TD>
<a id="oldcontent" href="ID=22143"><u>Re-Submit</u></a>
<a id="oldcontent" href="ID=22143"><u>View</u></a>
<TR>
Here i need to click the tag with Re-Submit text.The issue is href="ID=22143",id value gets generated dynamically everytime i execute the test case.So i need to click the Re-submit tag using text present in first text,i.e Foot-OM.Can anyone provide me the xpath>
Upvotes: 5
Views: 36058
Reputation: 4621
You can click on it like this :
selenium.click("//a/u[contains(text(),'Re-Submit')]");
For Webdriver :
driver.findElement(By.xpath("//a/u[contains(text(),'Re-Submit')]")).click();
Upvotes: 8
Reputation: 479
U can simply write 1.selenium.click("link=Re-Submit") and 2.selenium.click("link-View").
Upvotes: 0
Reputation: 1788
Looks like your problem is in incorrect HTML structure. Tag <a>
can't be put into <tr>
. Only <td>
is allowed there. Browser "fixes" errors and your tags <a>
appear outside the table and DOM-structure is not the same as html.
This XPath works for the picture above
//td[text()='Foot-OM']/../../../../a[//text()='Re-Submit']
Upvotes: 0
Reputation: 8548
In ruby Selenium webdriver
@driver.find_element(:link, "Re-Submit" ).click
using selenium RC perl
$sel->click("link=Re-Submit");
Upvotes: 2