title: Selenium clicking a link where the href is javascript:void[0];
body: <p>I'm trying to see if when a link is clicked a report is generated on the page using Selenium WebDriver with Java.</p>
  
  <p>What happens is there are a bunch of links on a page, most of them when clicked go to another page where I have automated filling in the details and submitting the form to check the report is generated. </p>
  
  <p>However, there are three reports that when clicked cause some JS to run and after a few seconds, a new link is displayed on the same page to download the report.</p>
  
  <p>How can I click this link? </p>
  
  <p>I am reading all the links on the page into a list of WebElements then looping through them for where the href contains javascript:  to void[0];</p>
  
  <p>I then try calling the click method on that element in the list, allLinks.get(i).click(); </p>
  
  <p>This is the same thing I do for the other reports and it works fine but on these 3 I get an error
  "Element is not currently visible and so may not be interacted with"</p>
  
  <p>Using firebug if I inspect the link that starts the JS running it says:</p>
  
  <pre><code>&lt;a onclick="requestReportGeneration('2cad4d4e5c8855c47a88b6ddf8345735', 'reportDiv33','CSV')" href="javascript:void[0];"&gt;CSV&lt;/a&gt;
  </code></pre>
  
  <p>Can anyone suggest a way to click the link?</p>
  
  <p>The page contains lots of links that say CSV so I can't just use the link text.</p>
  
  <p><strong>UPDATE:</strong>
  I've just had a thought about this which might help. When I first come to the page with the report links it will say "Order reports" I need to click the heading which then calls a JS function to expand that section and display the links. </p>
  
  <p>The reports that work because when I come to this page I just read all the hrefs of the page source and do driver.get(reportList.get(i);  so I'm not actually clicking on the link.</p>
  
  <p>I have added a link to get the xpath of the heading and click it but then when I try to click the link with the href or javascript: void I still get an error saying it's not visible.</p>