For future reference if someone else runs into this problem, here was the hack solution I came up with:
In the web.config file for my main program, I commented out the line
just for the duration of when I want to run my unit tests. This way, when I want to release from my localhost to my server, I can just take out the comments and everything still has the security that I needed for the main page.
Also, on all of my URLs for the Browser.GetPage() calls, I made sure to set them to read to my
http://localhost:port#/....aspx instead of calling to the main server.
After doing that, all of the unit tests passed. This probably isn't the best solution to the problem, but it does give you a single point of control when you want to run your unit tests, just make sure to comment out the deny users line in the config file, but don't forget to take out the commenting before releasing it back to the server!
--This was simply the solution I came up with, and I posted it here should anyone else arrive at the same problem and look for a solution--
Heather
I've been searching for a way to test this control with my NUnitASP tests for awhile now and have yet to come up with anything. I have all of my tests written, but until I can get past the initial login page, all my tests fail.
Here is some of the login page code:
- <asp:Login ID="Login1" runat="server" Height="134px"
-
OnAuthenticate="Login1_Authenticate"
-
OnLoginError="OnLoginError" Width="336px" CreateUserText="Create a new account" CreateUserUrl="CreateUser.aspx" DestinationPageUrl="~/Main.aspx" MembershipProvider="SqlProvider" PasswordRecoveryText="Retrieve Password" PasswordRecoveryUrl="PasswordRecovery.aspx">
-
</asp:Login>
On my NUnit tests, this is the code I have written so far...
- Browser.GetPage(MyPageURL);
-
// This is where I need to know the control tester for my login control
-
// in order to use it instead of CurrentWebForm for the following
-
TextBoxTester user = new TextBoxTester("UserName", CurrentWebForm);
-
TextBoxTester password = new TextBoxTester("Password", CurrentWebForm);
-
ButtonTester logon = new ButtonTester("LoginButton", CurrentWebForm);
-
-
user.Text = "validusername";
-
password.Text = "validpassword";
-
logon.Click();
I put a writeline into my unit test right after the getpage call and it was returning the correct page, but the error message given when I run the unit test is:
NUnit.Extensions.Asp.HtmlTag+ElementNotVisibleExce ption : Couldn't find 'UserName' on ' '.
Thanks,
Heather