I am currently working on using Selenium's HtmlUnitDriver and WebElement classes in Java to automate clicking the "Download as CSV" button on Google Trends.
The issue that I am encountering is that the button remains hidden until another settings menu button is clicked, but I am unable to trigger this action using WebElement.
Below is the snippet of my code:
/**
* @args String, the term to search on Google Trends
*/
public static void main(String[] args)
{
//initialize HtmlUnitDriver
HtmlUnitDriver hud = new HtmlUnitDriver();
//navigate to the 90-day Google Trends page for the specified term in args
hud.get("https://www.google.com/trends/explore#q=" + args[0] + "&date=today%203-m&cmpt=q&tz=Etc%2FGMT%2B8");
//point to the first button for activation
WebElement element = hud.findElement(By.id("settings-menu-button"));
//click on the element
element.click();
}
The error message I receive is: org.openqa.selenium.ElementNotVisibleException: You may only interact with visible elements
However, the settings menu button is clearly visible. What could be causing this issue?
This is my first attempt at creating such a program and using this library, so any guidance would be greatly appreciated. I am still in the learning process. Thank you.