javascriptpythonseleniumhyperlinkclicking

Clicking javascript link in Selenium using Python Not Working


I am trying to click a link on a webpage This is part of the source code:

<td height='12'><img src='/cs/cnyhcprd/cache850/PT_PIXEL_1.gif' alt='' /></td>
<td nowrap='nowrap'  valign='top' align='left'>
<DIV id='win0divDERIVED_SSS_SCR_SSS_LINK_ANCHOR3'><span  class='PSHYPERLINK'><a name='DERIVED_SSS_SCR_SSS_LINK_ANCHOR3'   id='DERIVED_SSS_SCR_SSS_LINK_ANCHOR3' tabindex='34' href="javascript:submitAction_win0(document.win0,'DERIVED_SSS_SCR_SSS_LINK_ANCHOR3');"  class='PSHYPERLINK' >Enroll</a></span>
</DIV></td>
</tr>

I have tried various variations of:

driver.find_element_by_id("win0divDERIVED_SSS_SCR_SSS_LINK_ANCHOR3").click()

My error message is essentially:

NoSuchElementException: Message: Unable to locate element:

Does anyone know what's wrong? I've been working on this issue for days already.


Solution

  • Figured it out.

    tl;dr Make sure to watch out for iFrames.