I want to scroll inside the text field

I can’t check the checkbox unless I scroll the contents of the text field to the end, but I don’t know how to scroll inside the text field. Could someone please give me some advice?
Thank you.

kindly share the html or logs or error trace to help out

Please look into doc [WebUI] Scroll To Element | Katalon Docs

You can try to use the “scrollToElement()” options as @atul.rai suggests and you may even try WebUI.scrollToPosition(100, 99999) to see if that works too.

What I was thinking though is to create a StringBuilder that contains lots (AND LOTS) of line feeds that you set in the text field and see if that does anything.

StringBuilder strB = new StringBuilder()
for (int cnt = 0; cnt < 100; cnt++) {
    strB = strB.append("\n")
}
strB.append("MagicText")
WebUI.sendKeys(findTestObject(...), strB.toString())

Another idea would be to try WebUI.clickOffset(findTestObject(...), XPos, YPos) but this one would need a fair bit of study of your element’s size, etc. and some math.

Edit: There was an OP in this forum that used scrollToElement to scroll in a drop-down list to find a specific reference in the list. You might be able to use the StringBuilder to create a chain with a specific text at or near the end and then scrollToElement to that text. You would need to create a parameterized Object in either code or the OR and replace your parameter with the text you want to scroll to, such as “MagicText”.

WebUI.scrollToElement(findTestObject('...',  [('my text'): "MagicText"]), 2)

Edit2: I made the assumption that your text field was empty. If it is not, then perhaps just search for a text string. or phrase, that is near the last of the characters within the text field and go with the concept of the scrollToElement.

hi @y_tugawa

the checkbox enables when the field’s own scroll position reaches the bottom, so you need to scroll the element, not the page. scrollToElement and scrollToPosition move the window. set scrollTop on the element and fire the scroll event the app listens for:

WebUI.executeJavaScript('''
  const el = arguments[0];
  el.scrollTop = el.scrollHeight;
  el.dispatchEvent(new Event('scroll', { bubbles: true }));
''', [WebUI.findWebElement(findTestObject('textarea_terms'))])
WebUI.waitForElementClickable(findTestObject('chk_agree'), 5)

if the terms are in a div with overflow auto instead of a textarea, same code, same element. some implementations check on wheel rather than scroll, in that case send a wheel event too, or use the actions api scrollByAmount with the element as origin.

hope your issue is resolved by now?

If you want to scroll inside a text field in Katalon, try clicking the field first and then using the mouse wheel or keyboard arrow keys. If it’s a web element, you may need to use JavaScript or Selenium to focus on the element and scroll it into view. Also, make sure you’re targeting the text field itself rather than the surrounding container.

Yes, points worth noting and trying

Good answer, scrolling the element itself (not the window) is the key. A few extras:

  1. Verify it reached the bottom before clicking: el.scrollTop + el.clientHeight >= el.scrollHeight - 1. On zoomed or scaled displays it can end up 1px short, so retry if false.
  2. If the terms load lazily, scrollHeight grows after the first scroll, so repeat until it stops changing.
  3. If the field sits inside an iframe, call WebUI.switchToFrame first, otherwise findWebElement won’t find it.
  4. If the app ignores the scroll event, click into the field and send Keys.chord(Keys.CONTROL, Keys.END) via WebUI.sendKeys as a keyboard fallback.

I also prefer JS way if normal way doesn’t work

Always native first and JS/other options

Yes, I admit