sWindowTitle set at runtime

Aug 8, 2012 at 9:40 PM
Edited Aug 8, 2012 at 9:41 PM

The site I'm testing is using friendly url's.

Therefore, the product display page will use the product display name ex: "Everglades" or "Dunes" at runtime.

But, given that I must define the sWindowTitle parmeter at runtime, I can't reuse my page definition for different products.

namespace MyAutomation.Emall
{
    public class eMallProductDisplayPage : EmallBasePage
    {
        // Required string that defines page (and therefore is no good for Dunes)
        public new string sWindowTitle = "Everglades";

        // Page Controls
        public CUITe_HtmlHyperlink uiBreadCrumbHomeLink = new CUITe_HtmlHyperlink("Class=item;InnerText=Home");

        ...etc...
     }
 }
 
In my calling test case I have...

Emall.eMallProductDisplayPage eMallProductDisplayPage = CUITe_BrowserWindow.GetBrowserWindow<Emall.eMallProductDisplayPage>();

How can I specify the page title at runtime?

Thanks,

Al
 

Coordinator
Aug 10, 2012 at 10:20 AM

Hi Al,

See an explanation of a similar request by sureba here:

http://cuite.codeplex.com/workitem/607

I personally would like to have support for this feature request as well since it will minimize duplicate code.

Aug 15, 2012 at 4:49 PM

I don't see how this would work with the CUITe_BrowserWindow.GetBrowserWindow<T>() method. I think we need a function to include a paramater here, so CUITe_BrowserWindow.GetBrowserWindow<T>("PageTitle"). This would override the specified sWindowTitle when it is picking up the page.

This way we can have one class to handle the functionality of the page where the title is dynamic (like a search results page).

So in ObjectRespositoryManager.cs we would have a method

private static CUITe_BrowserWindow GetInstance(Type typePageDefinition, string windowTitle)
{
CUITe_BrowserWindow browserWindow = (CUITe_BrowserWindow)Activator.CreateInstance(typePageDefinition);
browserWindow.SetWidowTitle(windowTitle);

... rest of code (i'm sure we could probably be smart here and not duplicate the code in object repository for the overloaded method

}

And CUITe_BrowserWindow.cs would have

public static T GetBrowserWindow<T>(string windowTitle)
{
return (T)(object)ObjectRepositoryManager.GetInstance<T>(windowTitle);
}

 

 
Coordinator
Aug 30, 2012 at 2:05 AM

Hi Al,

The requested changes have been implemented in changeset #19710.

I created a new class, CUITe_DynamicBrowserWindow, inherits CUITe_BrowserWindow, and contains a "T GetBrowserWindow<T>(string title)" method.

There are some unit tests that illustrate the functionality in Sample_CUITeTestProject\BrowserWindowTests.cs, specifically GetBrowserWindow_WithDynamicWindowTitle_CanGetNewWindowTitle and GetBrowserWindow_WithDynamicWindowTitle_CanInteractWithWindow.

For your sample, please try

public class eMallProductDisplayPage : CUITe_DynamicBrowserWindow
{
 public eMallProductDisplayPage()
  : base("Everglades")
 {
 }

 public eMallProductDisplayPage(string title)
  : base(title)
 {
 }

 // Page Controls
 public CUITe_HtmlHyperlink uiBreadCrumbHomeLink = new CUITe_HtmlHyperlink("Class=item;InnerText=Home");

 ...etc...
}

Emall.eMallProductDisplayPage eMallProductDisplayPage = CUITe_DynamicBrowserWindow.GetBrowserWindow<Emall.eMallProductDisplayPage>("Dunes");

 

Thank you.

Coordinator
Aug 30, 2012 at 5:37 AM

You can also call the SetWindowTitle(string title) method to set the window title of the browser used when searching for controls.