Search code examples
javahtmlseleniumhtmlunit

Clicking on links without an ID or name


I would like to locate the following anchor but not by its href. I have tried Htmlnit and Selenium. What i want to do is as mentioned locate the anchor and clicking on it, followed by getting the url i was directed to. However besides from i cannot locate the anchor and clicking on it, i get a bunch of error messaging complaining about the java script on the website.

< a href="/filingFrameset.asp?FileName=0001193125%2D14%2D302730%2Etxt&FilePath=%5C2014%5C08%5C08%5C&CoName=GENPACT+LTD&FormType=10%2DQ&RcvdDate=8%2F8%2F2014&pdf=" onmouseover="window.status='10-Q - GENPACT LTD - 8/8/2014'; return true;" onmouseout="window.status=''; return true;" target="fetchFiling">10-Q

WARNING: Obsolete content type encountered: 'application/x-javascript'. okt 05, 2014 3:18:41 EM com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify


Solution

  • You just want to know the URL of the current Page.

    You could use:

    <script>
    
    alert(window.location.href);
    
    </script>