Thank you for reviewing my query. On a webpage, there are more than 200 links & I've ensure all are working. This is easy after fetching href
value but the problem is, the 'href' value doesn't contain a link
rather a 'javaScript function' Here is a source
<a tabindex="8" title="Internal Crossload" target="_self" href="javascript:fnnHomePage('3' , 'WTMS_EXPRESS')"> - Internal Crossload </a>
JavaScript function:
<Script>
/*********************************************************************
Function Name : fnnHomePage
Input Parameter(s) : transferTypeId
Output Parameter(s) : None
**********************************************************************/
function fnnHomePage(transferTypeId ,moduleName) {
if (moduleName == "XXX_EXPRESS")
{
document.getElementById("transferTypeId").value=transferTypeId;
document.getElementById("gadgetType").value="XXX_EXPRESS";
document.getElementById("moduleName").value="XXX_EXPRESS";
document.forms[0].action="/XXX/getProposalHomePage.do?transferTypeId="+transferTypeId;
document.forms[0].submit();
}
if (moduleName == "CROSSLOAD")
{
document.getElementById("transferTypeId").value=transferTypeId;
document.getElementById("gadgetType").value="CROSSLOAD";
document.getElementById("moduleName").value="CROSSLOAD";
document.forms[0].action="/XXX/getCrossLoadHomePage.do?transferTypeId="+transferTypeId;
document.forms[0].submit();
}
}
</Script>
From the above code, how to I get a 'Link' and check if it is working fine in selenium webdriver? There are several links & each one calls a different 'JavaScript function'.Any suggestions will be appreciated. Thank you.
You may use a simple trick- click on the link. It will redirect you to the new link generated by javascript function. Then, get the link using driver.getCurrentUrl();
and go back to your original page and do your stuff as usual.
I hope, this makes sense.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With