[WebUI] Scroll To Element


This is a companion discussion topic for the original entry at https://docs.katalon.com/katalon-studio/docs/webui-scroll-to-element.html

This doesn’t do anything if the element is within the viewport but covered by a floating/static element, such as a header or footer. Can you fix it so that it detects that issue, or center the element?

You can read the source code of the ScrollToElement keyword at

It just calls a single line of Javascript as follows

((JavascriptExecutor) DriverFactory.getWebDriver())
        .executeScript("arguments[0].scrollIntoView();", webElement)

You can do a similar action using Built-in Keyword WebUI.executeJavascript()

So, if the script “arguments[0].scrollIntoView();” does not solve your problem, then you can rewrite the javascript to solve it for yourself.

That is a unique requirement. You should try to help yourself.

It’s not that unique of a requirement. Most websites have floating elements. I think the opposite situation is more unique to be honest. All Katalon has to do is update their call to scrollIntoView to pass in the options for centering the element: scrollIntoView({block: ‘center’}). Sure I can do that myself with custom code, but why should I need to for a common situation, and probably the most frequent use case for this function?

Perhaps the Katalon developers are busy to solve other problems.

Why not you try it first and, when successful, share the solution here and say

“Look, this is what you should implement in your product.”

Way ahead of you. Thank you for sharing the link to the source code for this. I created an issue and PR with the change I suggested and already used in my own project.

@cscott

I am afraid that Katalon team will not notice your Pull Request to that GitHub repository.

Why?

Katalon Studio is not an open-sourced project. That GitHub repository is a partial clone of their internal source code repository just for publicity purpose. They would never pay attention to the issues and PR to it.

You should make a offical support request here : Katalon Help Center if you are a paying licensee.

If you are not qualified to create a ticket, then post in this Forum with “Feature Request” category with copy&pate your achievement with mentioning @Jass, @duylong

Hello,

Am new to this katalon tool, may i know how to apply this in this specific code? Also this is not editable.

Please help.

Are you aware what you are looking at? What do you mean by “this specific code”?

The code fragment you quoted as “this specific code” is the implementation of the “WebUI.scrollToElement” keyword itself.

I interpreted your question to:

“may i know how to apply the WebUI.scrollToElement keyword in the implementation code of WebUI.scrollToElement”

Your question doesn’t make any sense.


If you just want to know how to use the keyword in you Test Case script, see

https://docs.katalon.com/katalon-studio/docs/webui-scroll-to-element.html