Skip to content

[🐛 Bug]: WebElement.click() does not properly scroll element into view (scroll "jerks" a few pixels but fails to make element clickable) #16345

@USSQA

Description

@USSQA

What I was trying to do:
Click an off-screen element on a public webpage using WebElement.click().

Expectation
Per the click specification, .click() should automatically scroll the element fully into view so it can be interacted with.

Observed Behavior:
Instead of fully scrolling the element into view, the browser scrolls only a few pixels (appearing to "jerk" a few times) and then stops. The element remains obscured and out of the view, and the click fails with an ElementClickInterceptedException.

Downstream reports:
Selenide #2850, #2882

Relevant context / configuration:

  • Reproduced on Windows 11 and Alpine Linux 3.22
  • Selenium 4.35.0 (Java bindings)
  • Google Chrome Version 140.0.7339.128 (Official Build) (64-bit)
  • Chromium Version 140.0.7339.185-r0 (Official Build) (64-bit)
  • Chromedriver auto-managed
  • Behavior is the same in headless and headed mode
  • Increasing viewport size (e.g., 1920x1080) does not avoid the bug

Error message:
org.openqa.selenium.ElementClickInterceptedException: element click intercepted: Element is not clickable at point (362, 1663)

Demonstration:
Image

Reproducible Code

import org.junit.jupiter.api.RepeatedTest;
import org.openqa.selenium.By;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class DemoScrollBug {

    @RepeatedTest(10)
    void demo() {
        WebDriver driver = new ChromeDriver();
        try {
            driver.manage().window().setSize(new Dimension(1920, 1080));
            driver.navigate().to("https://www.microsoft.com/en-us/microsoft-365/online-surveys-polls-quizzes");
            driver.findElement(By.xpath("//button[span[contains(text(), 'Organize your life')]]")).click();
        } finally {
            driver.quit();
        }
    }

}

Debugging Logs

org.openqa.selenium.ElementClickInterceptedException: 
element click intercepted: Element is not clickable at point (370, 1675)
  (Session info: chrome=139.0.7258.154)
Build info: version: '4.35.0', revision: '1c58e5028b'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.14.0-570.32.1.el9_6.x86_64', java.version: '21.0.8'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Command: [2ce61b925c8510c202a75b112c59ab8f, clickElement {id=f.64897B940898240B98A1C5FF2907869D.d.8A7487F6B30E9933667D7146120809E1.e.51}]
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 139.0.7258.154, chrome: {chromedriverVersion: 139.0.7258.154 (9e0d6b2b47f..., userDataDir: /tmp/.org.chromium.Chromium...}, fedcm:accounts: true, goog:chromeOptions: {debuggerAddress: localhost:45675}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: linux, proxy: Proxy(), se:cdp: ws://localhost:45675/devtoo..., se:cdpVersion: 139.0.7258.154, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:extension:minPinLength: true, webauthn:extension:prf: true, webauthn:virtualAuthenticators: true}
Element: [[ChromeDriver: chrome on linux (2ce61b925c8510c202a75b112c59ab8f)] -> xpath: //button[span[contains(text(), 'Organize your life')]]]
Session ID: 2ce61b925c8510c202a75b112c59ab8f
	at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486)
	at org.openqa.selenium.remote.ErrorCodec.decode(ErrorCodec.java:167)
	at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:138)
	at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:50)
	at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:215)
	at org.openqa.selenium.remote.service.DriverCommandExecutor.invokeExecute(DriverCommandExecutor.java:216)
	at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:174)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:557)
	at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:223)
	at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:76)
	at DemoScrollBug.demo(DemoScrollBug.java:15)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at java.base/java.util.Optional.ifPresent(Optional.java:178)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
	at java.base/java.util.stream.IntPipeline$1$1.accept(IntPipeline.java:180)
	at java.base/java.util.stream.Streams$RangeIntSpliterator.forEachRemaining(Streams.java:104)
	at java.base/java.util.Spliterator$OfInt.forEachRemaining(Spliterator.java:712)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions