18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
Identification of Scroll bar
Hi,
I have a requirement for identifying scroll bars in a web page. Can anyone please help me in identifying scroll bars through Sahi. The scroll bars are not identified when spyed. Is there any function or other method to do this?
I have a requirement for identifying scroll bars in a web page. Can anyone please help me in identifying scroll bars through Sahi. The scroll bars are not identified when spyed. Is there any function or other method to do this?
Comments
Can you tell why you want to identify the scrollbar? What is the end goal?
Javascript does not allow you to directly access the scrollbar, though you can scroll to a particular point on the page.
Regards,
Narayan
var $nTop = _eval("document.body.scrollTop");
var $nCHeight = _eval("document.body.clientHeight");
_alert($nHeight + " " + $nTop + " " + $nCHeight);
if (_condition($nHeight > ($nTop + $nCHeight))) {
//bar present
}else{
//bar not present
}
Thanks for the answer. I have a question though. Why is the scrollTop being added to the scrollHeight?
Would it not suffice to just check if scrollHeight is greater than clientHeight?
We will also need to check that the overflow property of style is not "hidden".
Some info: http://www.quirksmode.org/dom/w3c_cssom.html
I am adding the overflow property check to your solution, removing scrollTop and moving it into a browser function. Let me know if this works for you.
Regards,
Narayan
it's not necessary to add the scrollTop .
if u want to know whether the scrollbar scrolled to the bottom. scrollTop is necessary .
In one of the above comments you mentioned
"Javascript does not allow you to directly access the scrollbar, though you can scroll to a particular point on the page."
I want to scroll down but sahi fails to identify that, could you please give a solution to that.
you could use _focus($element). The viewport will be moved so that this $element is visible.
Regards
Wormi
Thanks for the reply... but the scroll bar is an infinite scroll bar, I was able to assert if the scroll bar is present or not using Narayan's code in the above comments but could not focus on that scroll bar since it does not have a unique div id .
Even i have similar issue,like objects get loaded only when we scroll like in FB .so if i want to find the object and click what i can do for it?