I want to click submenu item using selenium webdriver which is invisible bydefault. It becomes visible on mousehover . I tried with some code and it is giving error as shown below
Caused by: org.openqa.selenium.remote.ErrorHandler$UnknownServerException: Element is not currently visible and so may not be interacted with.
Here the code:
Actions actions = new Actions(driver);
WebElement menuHoverLink = driver.findElement(By.linkText("RENT"));
//WebElement menuHoverLink = driver.findElement(By.className("current"));
actions.moveToElement(menuHoverLink);
WebElement subLink = driver.findElement(By.cssSelector("a[href='nemc.com/rentals/easy-rent']"));
actions.moveToElement(subLink);
actions.click();
actions.perform();