I've been using WatiN in C# for about 2 months now for quick checks for online surveys I develop. I've gotten pretty good with it but I'm still having one issue that I can't find an answer to. I know how to iterate through all the radio buttons on the page but I can't seem to find out how to make it only check one radio button in a group.
So far I've used radio collections to find all the radio buttons on the page. Then I'll use a foreach loop to check all the radio buttons. I mean yes, its doing exactly what I told it to do but how do I get it to only check one radio button out of a group instead of checking ever button on the page?
Is there such thing as radio button collections? Any articles, tips, or pointers would greatly be appreciate开发者_如何学God!
Are you sure they are in the same group?
Here is some sample code that works as I would expect it. Click one radio button and it selects while the others in the group deselect.
ie.GoTo("http://www.echoecho.com/htmlforms10.htm");
System.Threading.Thread.Sleep(2000);
ie.RadioButton(Find.ByName("group2")).Click();
System.Threading.Thread.Sleep(250);
ie.RadioButton(Find.ByName("group2") && Find.ByIndex(1)).Click();
System.Threading.Thread.Sleep(250);
ie.RadioButton(Find.ByName("group2") && Find.ByIndex(2)).Click();
Sleeps are in there just to give me enough time to scroll down on the page and watch what is happening.
精彩评论