You're using a WebBrowser
control. WebBrowser
is IE. If you want Chrome use something like Awesomium or PhantomJS.
Personally I just script PhantomJS, you can render the whole page or define a viewport size and render that directly to an image.
Pergunta
When trying to perform a C# code for webpage screenShots for chrome using WebBrowser Controller, what I get as a screenshot is the Webpage rendered by IE and not by Chrome(the site I tried to capture is rendered differently by Chrome, FireFox and IE).
Would you explain to me how to make a screenshot for the Webpage rendered by Chrome and not by IE?? Ps: I used ChromeDriver before but it was only capturing the visible part of the webpage, Thanks alot
this is the method to take the screen shot of a webpage
`public static void TakeScreenShotChrome(WebBrowser WB, string url, string path)
// Load the webpage into a WebBrowser control WebBrowser
{
WB.ScrollBarsEnabled = false;
WB.ScriptErrorsSuppressed = true;
WB.Navigate(url);
while (WB.ReadyState != WebBrowserReadyState.Complete)
{
//Application.DoEvents();
Thread.Sleep(1000);
}
// Take Screenshot of the web pages full width
WB.Width = WB.Document.Body.ScrollRectangle.Width;
// Take Screenshot of the web pages full height
WB.Height = WB.Document.Body.ScrollRectangle.Height;
Bitmap bitmap = new Bitmap(WB.Width, WB.Height);
WB.DrawToBitmap(bitmap, new Rectangle(0, 0, WB.Width, WB.Height));
bitmap.Save(path,ImageFormat.Png);
WB.Dispose();
}`