Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove Scrollbar in ChromeDriver, how to change http-agent?

I use IWebDriver driver = new ChromeDriver(options) in C#

When I take .GetScreenshot();, often see scrollbar, is there a way to remove it?

2nd question, how to mock/change http_agent in ChromeDriver?

like image 617
Eric Yin Avatar asked Feb 26 '12 00:02

Eric Yin


People also ask

How do I inspect scrollbar in Chrome?

Chrome DevTools: Scroll elements into the viewportRight click on the DOM node from the elements panel. Select Scroll into view.

How do I get rid of the scroll wheel in HTML?

Remove scrollbars by adding the tag "scrolling=no." Remove borders by adding the tag "frameborder=0."


1 Answers

Scrollbar issue:

  • Try using Chrome switches when starting webdriver. See http://peter.sh/experiments/chromium-command-line-switches/ or chrome://flags/ in Chrome.
  • You can also make Chromedriver open the url in a popup without scrollbars. You can do this using some Javascript.
  • Or you could create a user_data/Default/User StyleSheets/Custom.css similar to the one below and launch Chrome with {--user-data-dir=user_data}

Custom.css:

::-webkit-scrollbar {
  height: 10px;
  width: 10px;
  background-color: #999999;
  display: none;
}

html > ::-webkit-scrollbar {
  width: 0px;
  display: none;
}

::-webkit-scrollbar-thumb {
  background: #999999;
  display: none;
}

::-webkit-scrollbar-track-piece {
  background-color: #797979;
  display: none;
}
like image 113
joost Avatar answered Sep 27 '22 19:09

joost