tags:

views:

117

answers:

0

Hello,

I was trying to search the archives so as not to post a question that might already have been answered. I am a newbie with WatiN and am facing a problem with text areas.

Using Visual Studio I am trying to automate a web page testing The test involves filling a box with user’s contact info and submit a request to be contacted

The test runs really quickly and the text fields are filled and immediately cleared!

The submit button is clicked and the validation fails. The interesting thing is that the test only fails some of the times! And when it does, the error message points to different lines each time!

Interestingly, this does not happen when running the test in debug mode and using breakpoints.

Here’s the code:

           //Submit a request to be contacted
            TextField firstName = ie.TextField(Find.ByName("txtFirstName"));
            if(!String.IsNullOrEmpty(firstName.Text))
            firstName.Clear();
            firstName.AppendText("Mickey");

            TextField surname = ie.TextField(Find.ByName("txtSurname"));
            surname.Clear();
            surname.AppendText("Mouse");
            ie.WaitForComplete();

            TextField phone = ie.TextField(Find.ByName("txtHomeWorkPhone"));
            phone.Clear();
            phone.AppendText("02070671500");
            ie.WaitForComplete();

            TextField email = ie.TextField(Find.ByName("txtEmail"));
            email.Clear();
            email.AppendText("[email protected]");
            ie.WaitForComplete();

            Button submit = ie.Button(Find.ByValue("Submit"));
            submit.Click();

            ie.Div(Find.ById("divThanks"));
            ie.Div("divThanks").Text.CompareTo("Thank you");

            Assert.IsTrue(ie.ContainsText("Thank you"));

This code will populate the string "Mickey" within the text field firstName. But then inexplicably, it will delete it, before going on to type in "Mouse" into the surname text field.

Any suggestions?

Thanks in advance, Sarah Ancellotti