ashot icon indicating copy to clipboard operation
ashot copied to clipboard

How to remove the scrollbar ?

Open JakFlew opened this issue 7 years ago • 4 comments

When a page is captured, a scroll bar appears on the right side. How do you get rid of it?

JakFlew avatar Dec 14 '17 09:12 JakFlew

I think you can increase the delay after every scroll to get rid of scrollbar

vpinv avatar Dec 15 '17 08:12 vpinv

Can you explain it in detail?

JakFlew avatar Dec 21 '17 07:12 JakFlew

Add this line to the import section in your class: import org.openqa.selenium.JavascriptExecutor;

And add this line inside your method before taking the screenshot: ((JavascriptExecutor) driver).executeScript("document.body.style.overflow = 'hidden';");

It worked for me.

natalygoloborodko avatar Nov 15 '18 12:11 natalygoloborodko

If solution from natalygoloborodko doesn't work try:

driver.executeScript(
                "var style = document.createElement(\"style\"); style.innerHTML = \"::-webkit-scrollbar {display: none;}\"; document.body.appendChild(style);");

guda avatar Jan 31 '20 16:01 guda