C# Selenium highlight element

To highlight an element in a screenshot taken by Selenium, use the following function:

public void SaveScreenshotWithHighlightedElement(Screenshot screenshot, IWebElement element, string filename){
  using (var image = Bitmap.FromStream(new MemoryStream(screenshot.AsByteArray))){
    using (var graphics = Graphics.FromImage(image)){
        graphics.DrawRectangle(new Pen(Color.Red, 10), new Rectangle(element.Location, element.Size));
    }
    
    image.Save(filename);
  }
}