Reputation: 285
This is a little different than other scrollbar questions. I have a requirement to verify that a scrollbar does not exist. Before this functionality was developed I inspected the page and found an xpath "//*[contains(@id,'scroller')]". Now the code has been developed and there is no scrollbar but that xpath is still there. Here is the html snippet:
<div tabindex="-1" id="pt1:r1:0:pt1:t1::scroller" style="position: absolute; overflow: auto; z-index: 0; width: 456px; top: 32px; height: 119px; right: 0px;">
<div style="width: 456px; height: 119px; visibility: hidden;"></div>
</div>
I can't just do a
List<WebElement> a = driver.findElements(By.xpath("//*[contains(@id,'scroller')])
And then assert that s.size() == 0
because even though there is no scrollbar, that element is still there.
I also tried the
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", searchColumn);
Where searchColumn is the right-most column of the table (still in view) of the table that should no longer have a scroll bar. I thought this would assert if there was no scroll bar, but it did not.
Any idea how to verify no scroll bar is there?
Thanks
Upvotes: 1
Views: 1200
Reputation: 15400
Scorllbar is not a WebElement which you can find using Webdriver's findElement method.
Your developer might have modified the CSS property to hide the scorllbar.
Check this example. It is taken from W3Schools CSS demo.
div.scroll {
background-color: #00FFFF;
width: 100px;
height: 100px;
overflow: scroll;
}
div.hidden {
background-color: #00FF00;
width: 100px;
height: 100px;
overflow: hidden;
}
<p>The overflow property specifies what to do if the content of an element exceeds the size of the element's box.</p>
<p>overflow:scroll</p>
<div class="scroll">You can use the overflow property when you want to have better control of the layout. The default value is visible.</div>
<p>overflow:hidden</p>
<div class="hidden">You can use the overflow property when you want to have better control of the layout. The default value is visible.</div>
So, access the table element and check for the style attribute or check with the developer for the property he modified.
Upvotes: 1