# "Scroll To" command is interrupted by following command

**URL:** <https://forum.katalon.com/t/scroll-to-command-is-interrupted-by-following-command/170593>\
**Category:** Bug Report\
**Tags:** web-testing, bugs-report, katalon-studio\
**Created:** [April 8, 2025, 3:03am UTC](https://forum.katalon.com/t/scroll-to-command-is-interrupted-by-following-command/170593 "2025-04-08T03:03:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cburst](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/cburst/32/23869_2.png) [@cburst](https://forum.katalon.com/u/cburst)\
**Post date:** [April 8, 2025, 3:03am UTC](https://forum.katalon.com/t/scroll-to-command-is-interrupted-by-following-command/170593/1 "2025-04-08T03:03:42Z")

</div>

Summary:  
The “Scroll To Element/Position” command is interrupted by whatever command follows it.

Example:

```auto
WebUI.scrollToElement(findTestObject('button_Update'), 0)
WebUI.click(findTestObject('button_Update'))

```

(Assuming the browser is viewing the top of the page and button\_Update is at the bottom and not currently visible.)

Expected: Automation scrolls to the bottom of the page until button\_Update is as high on the page as possible, then clicks.  
Actual result: ScrollToElement is canceled and automation immediately tries to click button\_Update, which is not in view.  
Workaround: Add “WebUI.delay(1)” or other Wait command after every ScrollTo command.

Blocker: No. Workaround is easy to implement. But it is annoying having to update old scripts that previously worked fine with extra delays.

* * *

Operating System: Windows 11  
Katalon Studio version 10.1.1  
Environment: Chrome Version 135.0.7049.42

---

<div class="post-metadata">

**Author:** ![grylion54](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/grylion54/32/16265_2.png) [@grylion54](https://forum.katalon.com/u/grylion54)\
**Post date:** [April 8, 2025, 5:48am UTC](https://forum.katalon.com/t/scroll-to-command-is-interrupted-by-following-command/170593/2 "2025-04-08T05:48:15Z")

</div>

> [@cburst](#):
>
> WebUI.scrollToElement(findTestObject(‘button\_Update’), 0)

Try and snap your fingers in zero seconds. Too bad, you **failed**. Same as your statement. Instead, try:

`WebUI.scrollToElement(findTestObject('button_Update'), 10)`

Edit: since you are trying to get to the bottom of the page, you can also use:

`WebUI.scrollToPosition(300, 5000)`

with the last number large enough to get you to the bottom of your page. This version does not have a ‘timeOut’ parameter at all.

Edit2: You really do not want to scroll directly to your object but to an element about 2 cm (an inch) above it, so your object is in the viewport. If you are lacking objects around that desired position, you might use:

```auto
pItem = WebUI.findWebElement(findTestObject('button_Update'))
WebUI.scrollToPosition(300, pItem.getLocation().getY() - 100)

```

---

<div class="post-metadata">

**Author:** ![dineshh](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/dineshh/32/24488_2.png) [@dineshh](https://forum.katalon.com/u/dineshh)\
**Post date:** [April 8, 2025, 6:02am UTC](https://forum.katalon.com/t/scroll-to-command-is-interrupted-by-following-command/170593/3 "2025-04-08T06:02:10Z")

</div>

To resolve the issue where the `Scroll To` command is interrupted by subsequent actions (e.g., clicks) in Katalon Studio, follow these structured solutions instead of relying on `WebUI.delay`:

## **1. Use `WaitForElement` Commands**

Add explicit waits to ensure the element is **clickable** or **visible** after scrolling:

```auto
WebUI.scrollToElement(findTestObject('button_Update'), 0)
WebUI.waitForElementClickable(findTestObject('button_Update'), 10) // Wait up to 10 seconds
WebUI.click(findTestObject('button_Update'))

```

## **2. Use `retryOnFailure` (Custom Workaround)**

Create a **retry mechanism** to handle transient visibility issues:

```auto
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI

// Define a retry method
def clickWithRetry(retryCount) {
  for (int i = 0; i < retryCount; i++) {
    try {
      WebUI.scrollToElement(findTestObject('button_Update'), 0)
      WebUI.click(findTestObject('button_Update'))
      break // Exit loop on success
    } catch (Exception e) {
      if (i == retryCount - 1) {
        throw e // Fail test on final retry
      }
    }
  }
}

// Usage
clickWithRetry(3)

```

## **3. Verify Element Visibility with JavaScript**

Use JavaScript to confirm the element is in the viewport before clicking:

```auto
WebUI.scrollToElement(findTestObject('button_Update'), 0)

// Custom script to check element visibility
def isElementInViewport = CustomKeywords.'com.yourpackage.Keywords.isElementInViewport'(findTestObject('button_Update'))

if (isElementInViewport) {
  WebUI.click(findTestObject('button_Update'))
} else {
  throw new Exception("Element not in viewport after scrolling.")
}

```

**Custom Keyword `isElementInViewport`** :

```auto
@Keyword
def isElementInViewport(TestObject to) {
  def element = WebUiBuiltInKeywords.findWebElement(to)
  def jsExecutor = (JavascriptExecutor) DriverFactory.getWebDriver()
  return jsExecutor.executeScript("""
    var rect = arguments[0].getBoundingClientRect();
    return (
      rect.top >= 0 &&
      rect.left >= 0 &&
      rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
      rect.right <= (window.innerWidth || document.documentElement.clientWidth)
    );
  """, element)
}

```

## **4. Use Enhanced WebUI Keywords (if available)**

Upgrade to **Katalon Studio 8.6.5+** and use the `Enhanced WebUI` plugin for built-in retries:

```auto
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import com.kms.katalon.core.webui.keyword.internal.WebUIAbstractKeyword as EnhancedWebUI

EnhancedWebUI.scrollToElement(findTestObject('button_Update'))
EnhancedWebUI.click(findTestObject('button_Update'))

```

## **5. Adjust Browser-Specific Settings**

For Chrome, add **experimental flags** to improve scrolling behavior in `DriverFactory`:

```auto
import org.openqa.selenium.chrome.ChromeOptions

ChromeOptions options = new ChromeOptions()
options.setExperimentalOption("forceDevToolsScreenshot", true) // Stabilizes rendering
options.setExperimentalOption("scrollBehavior", "smooth") // Smooth scrolling
WebUI.openBrowser('', options)

```

## **Why This Happens**

- **Asynchronous Execution:** Katalon Studio commands execute asynchronously. The scroll action may not complete before the next command (e.g., click) is triggered.
- **Browser/DOM Timing:** Modern browsers and frameworks (e.g., React/Angular) may delay rendering updates, causing elements to not be immediately interactive.

## **Best Practices**

- **Avoid `WebUI.delay`:** Use explicit waits (`waitForElementClickable`, `waitForElementVisible`).
- **Validate Visibility:** Use JavaScript or custom keywords to confirm elements are in the viewport.
- **Retry Mechanisms:** Implement retries for flaky interactions.

---

<div class="post-metadata">

**Author:** ![moath.abukharmh](https://avatars.discourse-cdn.com/v4/letter/m/e47c2d/32.png) [@moath.abukharmh](https://forum.katalon.com/u/moath.abukharmh)\
**Post date:** [April 15, 2025, 2:37am UTC](https://forum.katalon.com/t/scroll-to-command-is-interrupted-by-following-command/170593/4 "2025-04-15T02:37:26Z")

</div>

You can try to add a general delay for actions from **Project Settings \> Execution \> WebUI**

 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/3/d/3df6e3a6c33d1b3a4f1f23457f7a7ca3f175c6d5.png)

---

<div class="post-metadata">

**Author:** ![depapp](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/depapp/32/29178_2.png) [@depapp](https://forum.katalon.com/u/depapp)\
**Post date:** [October 1, 2026, 4:08am UTC](https://forum.katalon.com/t/scroll-to-command-is-interrupted-by-following-command/170593/5 "2026-10-01T04:08:48Z")

</div>

@cburst i think the scroll is not really cancelled, it is still animating. scrollToElement ends up calling scrollIntoView, and if your app has `scroll-behavior: smooth` on html or body (very common since 2024 in bootstrap / tailwind setups) the browser animates the scroll for a few hundred ms. the keyword returns immediately, the click computes the element position mid animation and misses or hits a sticky header. that matches “worked before, breaks now, delay fixes it”.

you can check in devtools: `getComputedStyle(document.documentElement).scrollBehavior`. if it says smooth, scroll without animation and center it so a fixed header cannot cover it:

```groovy
WebUI.executeJavaScript(
    "arguments[0].scrollIntoView({block: 'center', behavior: 'instant'})",
    [WebUI.findWebElement(findTestObject('button_Update'), 10)])
WebUI.click(findTestObject('button_Update'))

```

worth knowing too that selenium’s click already scrolls the element into view on its own, so in most cases the scrollToElement line can just go.
