My current task involves checking if clicking a link generates a report on the page using Selenium WebDriver with Java.
On the page, there are numerous links, most of which direct to another page where I automate filling in details and submitting a form to verify report generation.
However, there are three specific reports that trigger some JavaScript when clicked, followed by a new link appearing after a few seconds for downloading the report on the same page.
I am facing difficulty in clicking this particular link.
To tackle this issue, I have gathered all links on the page into a list of WebElements and then iterated over them to identify those with href containing javascript: void[0];
Subsequently, I attempted to click on the element in the list using the click method - allLinks.get(i).click();
This approach worked flawlessly for other reports, but it throws an error for these 3 reports stating "Element is not currently visible and so may not be interacted with"
Upon inspecting the link initiating the JS operation via firebug, the code snippet appears as:
<a onclick="requestReportGeneration('2cad4d4e5c8855c47a88b6ddf8345735', 'reportDiv33','CSV')" href="javascript:void[0];">CSV</a>
Seeking suggestions on how to successfully click this link?
Given that there are multiple links labeled CSV on the page, relying solely on the link text is not feasible.
UPDATE: A potential solution has crossed my mind. Initially, the page displays "Order reports" as the heading, which needs to be clicked to invoke a JS function expanding that section and revealing the links.
The reason why certain reports function smoothly is because upon reaching the page with the report links, I extract all hrefs from the page source and execute driver.get(reportList.get(i); without actually clicking the link.
I attempted obtaining the xpath of the heading and clicking it, however, even after doing so, I still encounter visibility issues when trying to click the link with href or javascript: void.