Selenium Window Scroll Element Into View

How do I use the Selenium Nodes to scroll the browser window and ensure an element is visible?

I often encounter the Selenium error "Element is not clickable at point(x,y). Other element would receive the click".

Some research suggests that I first need to ensure that the element is visible on the screen before it can be clicked. The sample JavaScript I've found looks like this:


... and ...

WebElement element = driver.findElement("id_of_element"));
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", element);

But I'm having trouble dropping this code into the Execute JavaScript Selenium node.

Even this simple script throws a "window.ScrollTo is not a function" error:

window.ScrollTo(0, 1000);

I'm using Firefox but have also encountered the same issue in Chrome. Any advice?


When you set up the Execute JavaScript node correctly, it should be as easy as:


arguments[0] is the element which should be scrolled into the view. You can retrieve it using the Find Elements node and then pass it as argument into the Execute JavaScript by selecting it in the left "Arguments" column:

(a bit further explanation: all arguments which you select in this column are passed into the arguments array, so the first selected item is available as arguments[0], the second as arguments[1], etc.)

I'm attaching a sample workflow which scrolls the KNIME forum's footer into the browser view.

Hope this helps.

[edit] Will probably provide the "scroll into view" functionality as a dedicated node in the future. Thanks for the pointer!

[edit2] This also worko, but note that the scrollTo function is written with a lowercase s:

  window.scrollTo(0, 1000);  
1 Like

Ah - lots of great information - thanks!