I have some textfields processed and other elements, but I want to get the bitmap so I can save it somewhere on disk. I need to do it directly from WatiN if this is possible
I don't think you can get the binary information directly from WatiN. However you have Image.Uri method give you the URI of the image. So then it is easy to download it wih http request.
using (Browser browser = new IE("http://www.sp4ce.net/computer/2011/01/06/how-to-use-WatiN-with-NUnit.en.html"))
{
Image image = browser.Images[0];
Console.Write(image.Uri);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(image.Uri);
WebResponse response = request.GetResponse();
using (Stream stream = response.GetResponseStream())
using (FileStream fs = File.OpenWrite(@"c:\foo.png"))
{
byte[] bytes = new byte[1024];
int count;
while((count = stream.Read(bytes, 0, bytes.Length))!=0)
{
fs.Write(bytes, 0, count);
}
}
}
Hope this helps