tags:

views:

629

answers:

2

Hi

I'm using WatiN for web application testing. There is a field called enter choices where i need to add 3 values one after the another by pressing enter key i.e., add 1st value then press enter key and Add 2nd value press enter key, so please suggest me how to make this work using WatiN.

thankingyou

A: 

Hi

The above method which jose has suggested, i made little changes to the code it worked for me. Jus replace TypeText by AppendText for entering the second value.

WatiN.Core.IE ie = new WatiN.Core.IE();

TextField txtChoices = ie.TextField(Find.ById("ctl00_ContentPlaceHolder1_TxtChoices"));

txtChoices.TypeText("NotBad");

System.Windows.Forms.SendKeys.SendWait("{ENTER}");

txtChoices.AppendText("VeryGood");

A: 

Here is another answer for the problem. When i passed enter key there it was giving a "Keyword delimiter is missing" error so instead i passe "\r\n" it worked fine.

WatiN.Core.IE ie = new WatiN.Core.IE():

TextField txtChoices = ie.TextField(Find.ById("ctl00_ContentPlaceHolder1_TxtChoices"));

txtChoices.TypeText("NotBad");

System.Windows.Forms.SendKeys.SendWait("\r\n");

txtChoices.AppendText("VeryGood");

System.Windows.Forms.SendKeys.SendWait("\r\n");

txtChoices.AppendText("Awesome");