public void Should_create_a_filestream() { var captureWebPage = new CaptureWebPage(Ie); try { var stream = captureWebPage.CreateFileStream(@"c:\capture_image_test.jpg"); Assert.That(stream, Is.Not.Null, "Expected a return value"); Assert.That(stream as FileStream, Is.Not.Null, "Expected a FileStream instance"); Assert.That(((FileStream)stream).Name, Is.EqualTo(@"c:\capture_image_test.jpg")); } catch (UnauthorizedAccessException ex) { Assert.That(ex.Message, Does.Contain(@"c:\capture_image_test.jpg")); } }
/// <summary> /// Captures the web page to file. The file extension is used to /// determine the image format. The following image formats are /// supported (if the encoder is available on the machine): /// jpg, tif, gif, png, bmp. /// If you want more control over the output, use the <see cref="CaptureWebPage"/> class. /// </summary> /// <param name="filename">The filename.</param> public virtual void CaptureWebPageToFile(string filename) { var captureWebPage = new CaptureWebPage(this); captureWebPage.CaptureWebPageToFile(filename, false, false, 100, 100); }
public void EmbedBrowserSnapshot(string attachmentName, Browser browser) { if (browser == null) throw new ArgumentNullException("browser"); try { var capture = new CaptureWebPage(browser); System.Drawing.Image image = capture.CaptureWebPageImage(true, false, 100); using (TestLog.BeginSection(browser.Url)) TestLog.EmbedImage(attachmentName, image); } catch { // Ignore the failure since the snapshot is for diagnostic purposes only. // If we can't capture it then too bad. } }