I was trying to test the a login page which used a
skinfile to render the login page. When I wrote a
test to test blank user names I kept getting an fail
because the NUnitASP could not find the login button
I'd name LoginButton in the skin file.
So may test looks like this
userName = new TextBoxTester("UserName",
CurrentWebForm);
password = new TextBoxTester("Password",
CurrentWebForm);
logon = new ButtonTester("LoginButton",
CurrentWebForm);
The Skin File has the following
<td align="right" colspan="2">
<asp:Button ID="LoginButton" runat="server"
CommandName="Login" Text="Logon"
ValidationGroup="Login1" />
</td>
I then browsed to the page and looked at the source
and spotted the problem. ASP.NET renames the ID for
the button to
"ctl00_ContentPlaceHolder1_Login1_LoginButton"
To get the test to pass I rename the ButtonTester
logon = new ButtonTester
("ctl00_ContentPlaceHolder1_Login1_LoginButton",
CurrentWebForm);
Now the test passes. This issue applies to validators
etc that are in a skin file. The upshot is you have
to write the page before the test because you don't
know the ID of the control
beforehand
Logged In: NO
I think this is more a problem of the master page.
You are seeing the naming containers.
I haven't used nUnitAsp in a while, but you should be able
to solve this the same way you test controls that are
inside other user controls.
You get "ctl00" from the masterpage, ContentPlaceHolder1
from the ContentPlaceHolder and the Login1 from the login
control.