Hi @mohamedjagrala !
Try this.
function ExecuteScript()
{
var scroller = document.getElementById('scroller');
if (scroller) {
// Get the scrollTop, clientHeight, and scrollHeight values
var scrollTop = scroller.scrollTop;
var clientHeight = scroller.clientHeight;
var scrollHeight = scroller.scrollHeight;
if (scrollTop + clientHeight >= scrollHeight) {
return 'You have reached the end of the scroller!';
} else {
return 'You have not reached the end of the scroller yet.';
}
} else {
return 'Scroller element not found.';
}
}
Use return statements and not console.log in the "Run JavaScript function on webpage" action as it returns a variable.
And please enclose your code within a function. It can be of any name like:
function ExecuteScript()
{
}
function CheckScroller()
{
}
I have added another check. That is to check whether scroller element exists or not. If it exists, it will do that calculation condition: scrollTop + clientHeight >= scrollHeight and if not, print not reached end of the scroller. If it doesn't exist, print 'Scroller element not found.'
You would be able to see the output of the action like given below:

I hope this helps.