[Nunitasp-users] New bee problem with Testing for Visibility of Controls from aspx pages using Mast
Brought to you by:
jlittle82
From: Kishore C. <kis...@gm...> - 2007-09-04 04:25:59
|
HI This is my first day with NUnitASP. I have searched everywhere, but found no example with this scenario. I can't seem make AssertVisibity(TestControl, true) to work when the page I'm testing is using a Master Page. I'm getting the following exception The same code works perfectly fine when the page being tested (Default2.aspx) does not use a master page. Any help would be really appreciated. Coz I really couldn't figure out. where I was going wrong. Exception NUnitAspSampleTest.Main.TestDefault2Page : NUnit.Extensions.Asp.WebAssertionException : Unexpectedly not visible: txtUsername (TextBoxTester 'txtUsername' in web form 'aspnetForm' in http://localhost/NUnitAspSample/Default2.aspx): txtUsername (TextBoxTester 'txtUsername' in web form 'aspnetForm' in http://localhost/NUnitAspSample/Default2.aspx) Files Default2.aspx (Which uses a master page MasterPage.master) <%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" Title="Untitled Page" %> <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> Sign Up Page:<br /> <br /> Username:<br /> <asp:TextBox ID="txtUsername" runat="server"></asp:TextBox><br /> Password:<br /> <asp:TextBox ID="txtPassword" runat="server"></asp:TextBox><br /> Re-Type Password:<br /> <asp:TextBox ID="txtPasswordReType" runat="server"></asp:TextBox><br /> <br /> <asp:Button ID="btnSignUp" runat="server" Text="Sign Up" /> <asp:Button ID="btnCancel" runat="server" Text="Button" /> </asp:Content> Main.cs (My Test Fixture) using System; using System.Collections.Generic; using System.Text; using NUnit.Framework; using NUnit.Extensions.Asp; using NUnit.Extensions.Asp.AspTester; namespace NUnitAspSampleTest { [TestFixture] public class Main:WebFormTestCase { TextBoxTester txtUsername; protected override void SetUp() { base.SetUp(); txtUsername = new TextBoxTester("txtUsername",CurrentWebForm); } [Test] public void TestDefault2Page() { Browser.GetPage("http://localhost/NUnitAspSample/Default2.aspx "); AssertVisibility(txtUsername, true); } protected override void TearDown() { base.TearDown(); txtUsername = null; } } } Cheers Kishore |