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

半世苍凉 提交于 2020-02-21 13:11:41

问题


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?


回答1:


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;
}


来源:https://stackoverflow.com/questions/9449562/how-to-remove-scrollbar-in-chromedriver-how-to-change-http-agent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!