Saturday, February 28, 2009

WatiN

I would like to thank the creator of WatiN, (Jeroen van Menen), and all of the contributors, you guys are awesome!!

There is allready a lot of documentation to the WatiN's Home site so if you are looking for a sample to get started go there.
Here is what I did with WatiN this Week.

There is a method in WatiN called CaptureWebPageToFile, which it capturees a screenshot and saves it to a file. But what I wanted to do is capture every page and save it to a word document so at the end of the test, I can go and quickly glanced at the pages to make sure that my website looks right, (i.e no broken images, broken links..etc).



so here's my solution;

//I creadted a new word document app

word = new word.ApplicationClass();

//open a word doc

word.visible = true;

//ceated a temp file to hold an image in C:

//then wala, capture the image with Wating, then insert it into a word doc


_ieBrowser.CaptureWebPageToFile("C:\\Test\\myImages.bmp");
_word.ActiveWindow.Selection.Range.InlineShapes.AddPicture(fileName, ref obj, ref obj, ref obj);

Did you do something similar or is this helpful?

No comments:

Post a Comment