Browser Basics

Apr 2, 2014 at 5:55 PM
Edited Apr 2, 2014 at 5:56 PM
Hello,
I realy want to use this framework as I have used it in the past. I haven't had the need to support Chrome until now :(

I have a very basic Object repository for a logon page : username, password, loginbutton.

My test case looks like this:
        CUITe_BrowserWindow.Launch("http://app/path/login.aspx");
        LogOn pgLogOn = CUITe_BrowserWindow.GetBrowserWindow<LogOn>();

        pgLogOn.txtLoginControlLoginID.SetText("logingname");
        pgLogOn.txtLoginControlPassword.SetText("loginpassword");
        pgLogOn.btnSignIn.Click();
This works great in in IE. Once I enable Chrome

BrowserWindow.CurrentBrowser = Chrome.Name;


I launches the app fine, but fails soon after with this error.

_Test Name: TmLogOn
Test FullName: PS.ObjectRepository.CodedUITest.TmLogOn
Test Source: d:\TFS_Quality Control\Frameworks\CUITe\Sample_CUITeSmartSolve\CodedUITest.cs : line 33
Test Outcome: Failed
Test Duration: 0:00:22.7347574

Result Message:
Test method PS.ObjectRepository.CodedUITest.TmLogOn threw exception:
Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotFoundException: Could not locate the browser window, window name not specified.
Result StackTrace:
at Microsoft.VisualStudio.TestTools.UITest.Extension.CrossBrowser.CrossBrowserFactory.Locate(PropertyExpressionCollection searchProperties, PropertyExpressionCollection filterProperties)
at Microsoft.VisualStudio.TestTools.UITesting.SearchHelper.SearchTopLevelWindow(ISearchArgument topLevelSearchArg, String topLevelElementQueryId)
at Microsoft.VisualStudio.TestTools.UITesting.SearchHelper.GetTitleUpdatedTopLevelWindow(ISearchArgument topLevelSearchArg, String queryId, IList1 windowTitles)
at Microsoft.VisualStudio.TestTools.UITesting.SearchHelper.GetTopLevelElement(Boolean useCache, Boolean useCacheOnly, ISearchArgument searchArg, IList
1 windowTitles, Int32& timeLeft)
at Microsoft.VisualStudio.TestTools.UITesting.SearchHelper.GetUITestControlRecursive(Boolean useCache, Boolean alwaysSearch, ISearchArgument searchArg, IList1 windowTitles, Int32& timeLeft)
at Microsoft.VisualStudio.TestTools.UITesting.SearchHelper.GetUITestControlRecursive(Boolean useCache, Boolean alwaysSearch, ISearchArgument searchArg, IList
1 windowTitles, Int32& timeLeft)
at Microsoft.VisualStudio.TestTools.UITesting.SearchHelper.GetElement(Boolean useCache, ISearchArgument searchArg)
at Microsoft.VisualStudio.TestTools.UITesting.SearchHelper.Search(ISearchArgument searchArg)
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.FindInternal()
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.FindControlIfNecessary()
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.WaitForControlReadyPrivate(Int32 millisecondsTimeout, Boolean doLogging)
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.<>c__DisplayClass1d.<WaitForControlReady>b__1c()
at Microsoft.VisualStudio.TestTools.UITesting.CodedUITestMethodInvoker.InvokeMethod[T](Func`1 function, UITestControl control, Boolean firePlaybackErrorEvent, Boolean logAsAction)
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.WaitForControlReady(Int32 millisecondsTimeout)
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.WaitForControlReady()
at CUITe.Controls.HtmlControls.CUITe_HtmlEdit.SetText(String sText) in d:\TFS_Quality Control\Frameworks\CUITe\CUITe\Controls\HtmlControls\CUITe_HtmlEdit.cs:line 12
at PS.ObjectRepository.CodedUITest.TmLogOn() in d:\TFS_Quality Control\Frameworks\CUITe\Sample_CUITeSmartSolve\CodedUITest.cs:line 42
_
Apr 3, 2014 at 12:48 PM
This ended up working for me.
      BrowserWindow.CurrentBrowser = Chrome.Name;

       CUITe_BrowserWindow window = CUITe_BrowserWindow.Launch("http://app/path/login.aspx","Application");
       LogOn pgLogOn = CUITe_BrowserWindow.GetBrowserWindow<LogOn>();
       pgLogOn.SearchProperties[UITestControl.PropertyNames.Name] = window.Title; 
       pgLogOn.txtLoginControlLoginID.SetText("logingname");
       pgLogOn.txtLoginControlPassword.SetText("loginpassword");
       pgLogOn.btnSignIn.Click();
       window.Close();
The keyline being:
pgLogOn.SearchProperties[UITestControl.PropertyNames.Name] = window.Title;

Without that line, CHROME does not work for me.
Apr 3, 2014 at 3:23 PM
Eduardo,

I'm looking at adding support in my automation suite for Chrome & had a question since you just got this working.

Do you just need to set the currentbrowser in the test method that opens the browser? or does it need to be set in each method that reuses the browser window?