Ok so I have been experimenting with Unit Testing. I am using Nunit and WatiN to do my testing and decided to try to implement the WatiN Test Recorder. I don’t know if anyone is familiar with it, but I am using the 2.0 build (beta) I have the following code pulled direcltly from the test recorder and only slightly cleaned up.
[TestFixture, RequiresSTA]
class WatiNTesting
{
[Test]
public void WatiNTest()
{
IE window = new IE("http://www.google.com");
TextField txt_q = window.TextField(Find.ByName("q"));
Element Locate = window.Element(Find.ByText("") && Find.ByValue("") && Find.ById("") && Find.BySrc("") && Find.ByUrl(""));
Link lnk_wwwvietnamesetestingboardorgzbxemiddownloadcategory197510 = window.Link(Find.ByUrl("http://www.vietnamesetestingboard.org/zbxe/?mid=download&category=197510"));
txt_q.TypeText("Watin");
Locate.Click();
lnk_wwwvietnamesetestingboardorgzbxemiddownloadcategory197510.Click();
window.Dispose();
}
}
Whenever I go to run it, the window opens to goolge then Nununit returns this error:
Failure: System.UriFormatException : Invalid URI: The hostname could not be parsed.
Does anyone know how to get rid of this error, or a way to get around it?
Ok, the first problem seems to be with the Find.ByUrl call on this line…
Remove it…
And it passes. Not really sure what you’re trying to accomplish here, but hope this helps.