Skip to content
This repository has been archived by the owner on Nov 29, 2018. It is now read-only.

Generic error in GDI+ when calling SaveAsFile for ScreenShot #4537

Closed
lukeis opened this issue Mar 4, 2016 · 7 comments
Closed

Generic error in GDI+ when calling SaveAsFile for ScreenShot #4537

lukeis opened this issue Mar 4, 2016 · 7 comments

Comments

@lukeis
Copy link
Member

lukeis commented Mar 4, 2016

Originally reported on Google Code with ID 4537

What steps will reproduce the problem?

Screenshot myScreenShot = ((ITakesScreenshot)driver).GetScreenshot();
string saveMe = saveLocation + "\\" + dtForFileName + ".jpg";
mybit.SaveAsFile(saveMe, ImageFormat.Jpeg);


The exception is thrown on SaveAsFile.

I have read solutions about not disposing the stream until after the save but I am
not creating my own stream, the SaveAsFile() function does that as shown below:

using (MemoryStream imageStream = new MemoryStream(this.byteArray))
            {
                Image screenshotImage = Image.FromStream(imageStream);
                screenshotImage.Save(filename, format);
            }





Selenium version: 2.24
OS: Windows 7
Browser: IE9
Browser version: 9.0.8112.16421



Reported by briandavid7324 on 2012-09-11 16:36:26

@lukeis lukeis self-assigned this Mar 4, 2016
@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Reported by barancev on 2012-09-12 09:17:06

  • Labels added: Component-WebDriver, Lang-CSharp

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Hi!

is this issue still reproducible? Please recheck it at latest Selenium version, please.

If the issue is still occured please provide full exception ifno, your test code and
html+css+js or pulic URL at which error is happened.

Reported by a.u.savchuk on 2013-04-19 22:45:45

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Reported by a.u.savchuk on 2013-05-07 11:17:59

  • Status changed: NeedsClarification

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Closing due to inactivity. Please ask to reopen if the issue is still actual.

Reported by a.u.savchuk on 2013-08-15 19:24:36

  • Status changed: Fixed
  • Labels added: Browser-IE

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Hi reopening this issue on Producing Screenshot on Safari driver on Mac OSX using .Net
Webdriver.



Reported by e.benito23 on 2014-03-14 10:39:15

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

This issue should be close, it's on the System.drawing library issue. 

Just to help in saving your screenshot. Use binary writer. 100% working

var screenshot = ((ITakesScreenshot)webDriver).GetScreenshot();
byte[] imageBytes = Convert.FromBase64String(screenshot.ToString());

using (BinaryWriter bw = new BinaryWriter(new FileStream(fileName, FileMode.Append,
FileAccess.Write)))
{
  bw.Write(imageBytes);
  bw.Close();
}



Reported by e.benito23 on 2014-03-20 07:26:08

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Reported by luke.semerau on 2015-09-17 18:16:08

  • Labels added: Restrict-AddIssueComment-Commit

@lukeis lukeis closed this as completed Mar 4, 2016
@SeleniumHQ SeleniumHQ locked and limited conversation to collaborators Mar 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant