Home > Back-end >  How to tell the animation in Chrome browser is not in motion?
How to tell the animation in Chrome browser is not in motion?

Time:03-04

Clicking an element always ended up failure. Just found the reason is that the element is not ready to click because it comes with some shaking animation even if Explicit wait method ExpectedConditions.elementToBeClickable(ele) is implemented. In debugging mode, I can click. Of course. But in run mode, no difference.

ElementClickInterceptedException This is the exception.

Any idea to tell that animation finished and actually ready to be clicked?

enter image description here

CodePudding user response:

My advice is to "hard-click" on the element via JavaScript:

WebElement element = driver.findElement(By.id("Element's ID Goes Here"));
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click();", element);

Tell me if this helped you or not.

CodePudding user response:

If Tal Angel's answer doesn't work for you, try using the Actions class to move to the element's position and force a click event.

Actions actions = new Actions(driver);
actions.moveToElement(ele).click().build().perform();

You will need to import org.openqa.selenium.interactions.Actions; to do this.

Runnable example here

  • Related