Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to remove the scrollbar ? #116

Open
JakFlew opened this issue Dec 14, 2017 · 4 comments
Open

How to remove the scrollbar ? #116

JakFlew opened this issue Dec 14, 2017 · 4 comments

Comments

@JakFlew
Copy link

JakFlew commented Dec 14, 2017

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

@vpinv
Copy link

vpinv commented Dec 15, 2017

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

@JakFlew
Copy link
Author

JakFlew commented Dec 21, 2017

Can you explain it in detail?

@natalygoloborodko
Copy link

natalygoloborodko commented Nov 15, 2018

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.

@guda
Copy link

guda commented Jan 31, 2020

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);");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants