Question regarding AnchorTester
Brought to you by:
jlittle82
In my web page I have a anchor tag which sets the
onclick event to point to a javascript function which is
used to open a new window, for example:-
<a href="#" id="someID" onclick="myJSFunction
('parameterUsedByJSFunction')">someValue</a>
In viewing the code of the "click" event for the
AnchorTester, it appears to determine if the anchor tag
contains an onclick event with an explicit "window.open"
javascript call. If it does, the onclick event is returned,
if not, the value of the HREF is used. Following the code
above, this has the effect of nothing happening as the
value of the href is used.
Is there any way in the current version of NUnitASP to
enable the functionality to be tested?
Logged In: YES
user_id=826251
You can't really test whether another window is created with
NUnitAsp since it really only tests server side code. What
you could do is just check that the attibute is set correctly
and treat the "onclick" event like a Golden Master, that is, it
doesn't need to be tested. So, i'd just use the following:
AssertEquals( "myJSFunction('parameterUsedByJSFunction')",
new AnchorTester( "someID", CurrentWebForm,
false ).GetAttributeValue( "onclick" ) );
To use logic like this, you would have to go into the
ControlTester class( i think ) and make the method public
instead of whatever scope it uses now. Recompile, and you
should be alright.
cliff