Re: [Watinfixture-users] Arrays of checkbox controls with differentVALUE's
Status: Alpha
Brought to you by:
kalnir
|
From: Jeff P. <Jef...@ex...> - 2007-09-14 19:02:07
|
Rob,
The first problem you have is that your controls are not uniquely named.
It would be easier if you named your controls uniquely.
<table>
<tr>
<td>User Id</td>
<td>Allowed</td>
<td>No allowed</td>
</tr>
<tr>
<td>
<input type=3Dcheckbox id=3DAllowed_1 name=3DAllowed =
value=3D"abc">
</td>
<td>
<input type=3Dcheckbox id=3DNotAllowed_1 name=3DNotAllowed
value=3D"abc">
</td>
</tr>
<tr>
<td>
<input type=3Dcheckbox id=3DAllowed_2 name=3DAllowed =
value=3D"123">
</td>
<td>
<input type=3Dcheckbox id=3DNotAllowed_2 name=3DNotAllowed
value=3D"123">
</td>
</tr>
</table>
The addition of ID should allow you to look up each control directly
without affecting your program.
Unfortunately, WatiNFixture is not currently designed to deal with
collections of controls like checkboxes that all have the same name.
If you look a little closer at the code, you'll see that UserActions
inherits from the DoFixture class. This class translates the function
names into plain sentences with spaces. For example,
public bool TakeMyAnd(string objectIdentifier, string actionValue)
The DoFixture class translates this into the plain sentence:
|take my|football|and|punt|
DoFixture somehow knows how to translate this and call the TakeMyAnd
function. The first unmatched item in pipe (|) symbols is the first
variable, the second unmatched item in pipe (|) symbols is the second
variable, and so forth.
As far as how to verify those checkboxes, the best way would be to give
each a unique id value, then use VerifyCheckboxIsChecked:
|verify checkbox|Allowed_1|is checked|
|verify checkbox|NotAllowed_2|is checked|
There's no method today to perform VerifyCheckboxHasValue, but this
command would be:
|verify checkbox|Allowed_1|has value|abc|
|verify checkbox|NotAllowed2|has value|123|
And its corresponding function would be:
public bool VerifyCheckboxHasValue(string checkboxID, string
checkboxValue)
However, it sounds like verifying the checkbox has that value is not
really what you're looking for.
WatiNFixture was written from the perspective of a user working with
your application. So one question you can ask is, if I put a checkbox
here and a checkbox here and hit submit, what does the user expect the
application to do?
If the user is supposed to see a confirmation message after the button
is clicked, check for that.
If this is for security and after the admin makes changes, the user's
experience is supposed to change, then you need to have WatiNFixture log
out the current test admin, login the test user that is supposed to be
affected, and check to make sure what is supposed to be shown is shown,
and what is not supposed to be shown is not shown.
Jeff
-----Original Message-----
From: wat...@li...
[mailto:wat...@li...] On Behalf Of
Rob MacFadyen
Sent: Friday, September 14, 2007 1:36 PM
To: wat...@li...
Subject: [Watinfixture-users] Arrays of checkbox controls with
differentVALUE's
Hey all,
=20
I have a web page that uses "arrays" of controls (i.e. the controls all
have
the same NAME value). For example imagine a web page that looks like:
User Id Allowed Not Allowed
------- ------- -----------
abc [ ] [ ]
123 [ ] [ ]
the HTML would look like (outlook syntax and formatting enabled):
<table>
<tr>
<td>User Id</td>
<td>Allowed</td>
<td>No allowed</td>
</tr>
<tr>
<td>
<input type=3Dcheckbox name=3DAllowed value=3D"abc">
</td>
<td>
<input type=3Dcheckbox name=3DNotAllowed value=3D"abc">
</td>
</tr>
<tr>
<td>
<input type=3Dcheckbox name=3DAllowed value=3D"123">
</td>
<td>
<input type=3Dcheckbox name=3DNotAllowed value=3D"123">
</td>
</tr>
</table>
On the server side of processing you end up with 2 arrays, Allowed and
NotAllowed, with entries only for CHECKED checkboxes... and the entry
values
are the specified values. Kind of goofy.... but this is _not_ asp.net
stuff.
So... my challenge is how to Verify/Check these critters?=20
What I need to do is specify an ID/NAME _and_ a VALUE.
Looking at the WatiNFixture code I can see that all the UserActions seem
to
follow the following pattern:
|MethodNamePrefix|A_User_Entered_Value|MethodNameSuffix|
But I'm unclear on how/why this is so.
What I'd like is:
|!-WatiN.Contrib.WatiNFixture.UserActions-!|
|open browser|
|navigate to|http://localhost/somedarntestpage|
|verify checkbox|TeamMember|value|abc|exists|
The code I think I need is:
public bool VerifyCheckboxValueExists(string checkboxID, string
checkboxValue)
{
// actually do something
return false;
}
But... I don't see how/where to wire up any of the plumbing for getting
two
values passed.
Also when I did a quick and dirty test (i.e. just added the code above)
now
my test crashes with:
System.TypeLoadException: Could not load type 'fitlibrary.FixtureBase'
from
assembly 'FitLibrary, Version=3D1.0.2339.33496, Culture=3Dneutral,
PublicKeyToken=3Dnull'.
at System.Reflection.Assembly.GetExportedTypes()
at fit.ObjectFactory.GetTypeOrInstance(TypeName typeName,
GetTypeOrInstanceDelegate getTypeOrInstance)
at fit.Fixture.LoadFixture(String className)
at fit.Fixture.DoTables(Parse tables
Which makes no sense to me either :)... after I compiled the changes I
just
copied the .dll over to my fitness/dotnet directory... is there
something
else I should be doing?
So... long and the short... I'm pretty lost :)
Any suggestions?
Regards,
Rob
ps. Note that once the basic verify checkbox by value works I'll want to
extend this to include "is checked", "is not checked", and somehow for
"check checkbox", "uncheck checkbox" and "click checkbox"... maybe with:
|check checkbox with value|<ID>|value|<VALUE>|
------------------------------------------------------------------------
-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Watinfixture-users mailing list
Wat...@li...
https://lists.sourceforge.net/lists/listinfo/watinfixture-users
|