Click on elements out of view / Scroll an element into view

30 views
Skip to first unread message

Georg Horn

unread,
Jan 18, 2018, 1:40:21 PM1/18/18
to Selenium Remote Driver
Hi,

Using selenium-server-standalone-3.8.1, geckodriver 0.19.1, Firefox 55 and S::R::D 1.20.

i had the problem that $elem->click(); did not work for elements that are out of view. There was no error but the click just did nothing.
According to https://w3c.github.io/webdriver/webdriver-spec.html#element-click the element should be scrolled into view before clicking on it, but obviously this does not work

I then tried to use $driver->mouse_move_to_location(element => $elem); because the manpage says "If the element is not visible, it will be scrolled into view.", but this did not work too. The mouse _is_ moved to the element, i see for example tool tips appear, but if the element is out of view the click still does not work

Finally i ended up with $driver->execute_script("arguments[0].scrollIntoView(false);", $elem);

Has anybody any further suggestions on this? Is it a bug in selenium, geckodriver or firefox?

George Baugh

unread,
Jan 19, 2018, 9:31:02 PM1/19/18
to Selenium Remote Driver
They implemented a check to see whether the element was able to be viewed that's basically bogus.

Any page with negative margins basically makes it think elements are invisible that clearly are.

The way to disable this is to pass extra_capabilities => { webdriverClick => 0 } when starting up the driver.

Or, in older drivers you can use the overlappingCheckDisabled=> 1 parameter.

Honestly, most of that stuff being bogus for so long made me just do JS clicks, as using execute_script is more reliable.  I wish we weren't spending more time fighting the tool than testing, but it is what it is.
Reply all
Reply to author
Forward
0 new messages