Problem with Exists property

Nov 27, 2012 at 2:23 PM

Hi,

I don't know if this is a problem with CodedUI as such or something to do with the CUITe framework.

In my OR I have created two classes based on CUITe_BrowserWindow:

public class HomeUI : CUITe_BrowserWindow
{
        public new string sWindowTitle = "Home";
}


public class ErrorUI : CUITe_BrowserWindow
{
      public new string sWindowTitle = "Error";
}

Note: The window titles are not the full title, they're working as a regex or contains statement.

The application is a SharePoint application and the window title changes when navigating between pages.

At certain points I am creating a reference to the "Error" browser window and checking if the "Error page" exists. The problem is that the pgError.Exists statement is always TRUE even when the window title is something else. Can anyone explain why?

ErrorUI pgError = CUITe_BrowserWindow.GetBrowserWindow<ErrorUI>

if (pgError.Exists)
{
    .........
    .........
}
Thanks in advance

Nov 28, 2012 at 1:03 PM

Ok,

 

So I'm being stupid in that there should only be one instance of BrowserWindow. Looks like I'll have to go back to having all my controls under one BrowserWindow class...

Coordinator
Jan 17, 2013 at 8:14 AM

Hi flapmio,

Please try to inherit from the new CUITe_DynamicBrowserWindow class instead.

Sample_CUITeTestProject\BrowserWindowTests.cs has a sample test as follows:

[TestMethod]
public void GetBrowserWindow_WithDynamicWindowTitle_CanGetNewWindowTitle()
{
    string page1GenericWindowTitle = "window title 1";
    string page1FullWindowTitle = "window title 1 - Windows Internet Explorer";

    //Arrange
    DynamicBrowserWindowTitleRepository home = CUITe_BrowserWindow.Launch<DynamicBrowserWindowTitleRepository>(CurrentDirectory + "/DynamicBrowserWindowTitle.html");

    home.btnGoToPage1.Click();

    //Act
    DynamicBrowserWindowTitleRepository page1 = CUITe_DynamicBrowserWindow.GetBrowserWindow<DynamicBrowserWindowTitleRepository>(page1GenericWindowTitle);

    //Assert
    Assert.AreEqual(page1FullWindowTitle, page1.Title);

    page1.Close();
}