Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to click <a> tag in selenium

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>

like image 831
cxyz Avatar asked Dec 27 '22 13:12

cxyz


2 Answers

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();
like image 153
Abhishek_Mishra Avatar answered Feb 08 '23 10:02

Abhishek_Mishra


In ruby Selenium webdriver

@driver.find_element(:link, "Re-Submit" ).click

using selenium RC perl

$sel->click("link=Re-Submit");
like image 40
Amey Avatar answered Feb 08 '23 10:02

Amey