Search code examples
javascriptxpathrobotframework

Inquiry About the Scroll Bar of the div Tag


While writing automation scripts in Robot Framework, I encountered an issue with the div tag scroll bar that caused data extraction to fail. Below is an HTML example:

<div id="box">
  <div class="rapper">

enter image description here

I'd like to inquire about how to specify the scroll movement for a div tag.

Thank you.

The following methods have been unsuccessful:

Execute Javascript document.getElementByClassName('rapper').scrollTop
Execute Javascript window.document.getElementByClassName('rapper').scrollTop

Solution

  • Here's the correct way to scroll a div element with a specific class using JavaScript:

    Execute Javascript  document.querySelector('.rapper').scrollTop = 100
    

    This assumes you want to set the scroll position to 100 pixels. Adjust the value as needed.