publicBitmapGetFullScreenshot(){
Bitmap stitchedImage =null;try{
long totalwidth1 =(long)((IJavaScriptExecutor)this.webDriver).ExecuteScript("return document.body.offsetWidth");//documentElement.scrollWidth");long totalHeight1 =(long)((IJavaScriptExecutor)this.webDriver).ExecuteScript("return document.body.parentNode.scrollHeight");int totalWidth =(int)totalwidth1;int totalHeight =(int)totalHeight1;// Get the Size of the Viewportlong viewportWidth1 =(long)((IJavaScriptExecutor)this.webDriver).ExecuteScript("return document.body.clientWidth");//documentElement.scrollWidth");long viewportHeight1 =(long)((IJavaScriptExecutor)this.webDriver).ExecuteScript("return window.innerHeight");//documentElement.scrollWidth");int viewportWidth =(int)viewportWidth1;int viewportHeight =(int)viewportHeight1;// Split the Screen in multiple Rectangles
List<Rectangle> rectangles =newList<Rectangle>();// Loop until the Total Height is reachedfor(int i =0; i < totalHeight; i += viewportHeight){
int newHeight = viewportHeight;// Fix if the Height of the Element is too bigif(i + viewportHeight > totalHeight){
newHeight = totalHeight - i;}// Loop until the Total Width is reachedfor(int ii =0; ii < totalWidth; ii += viewportWidth){
int newWidth = viewportWidth;// Fix if the Width of the Element is too bigif(ii + viewportWidth > totalWidth){
newWidth = totalWidth - ii;}// Create and add the RectangleRectangle currRect =newRectangle(ii, i, newWidth, newHeight);
rectangles.Add(currRect);}}// Build the Image
stitchedImage =newBitmap(totalWidth, totalHeight);// Get all Screenshots and stitch them togetherRectangle previous = Rectangle.Empty;foreach(var rectangle in rectangles){
// Calculate the Scrolling (if needed)if(previous != Rectangle.Empty){
int xDiff = rectangle.Right - previous.Right;int yDiff =