问题
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