There are a couple of ways to handle it , please see below :
Using action class for the click :
Link to Official documentation
As the method documentation says,
Call perform() at the end of the method chain to actually perform the actions.
The general way to achieve click using Actions class is below :
actionsObj.moveToElement(element1).click().build().perform()
If Actions class fails , sometimes the reason can be that you receive below exception :
ElementNotInteractableException [object HTMLSpanElement] has no size and location
That can mean two things :
a. Element has not properly rendered: Solution for this is just to use implicit /explicit wait
Implicit wait :
driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);
Explicit wait :
WebDriverWait wait=new WebDriverWait(driver, 20);
element1 = wait.until(ExpectedConditions.elementToBeClickable(By.className("fa-stack-1x")));
b. Element has rendered but it is not in the visible part of the screen: Solution is just to scroll till the element. Based on the version of Selenium it can be handled in different ways but I will provide a solution that works in all versions :
JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].scrollIntoView(true);", element1);
- Suppose all this fails then another way is to again make use of Javascript executor as following :
executor.executeScript("arguments[0].click();", element1);