Issue in Cross Browser Coded UI Testing

Jul 26, 2013 at 10:38 AM
I have an issue while running my coded ui test script in “Chrome” browser. Its working fine with both IE and Firefox.

Failed Test Trace:
Result2 Name: WikiTest (Data Row 1)
Result2 Outcome: Failed
Result2 Duration: 0:00:43.111558
Result2 Message:
Test method MyFirst.CodedUI2012.TestProject.CodedUITest1.WikiTest threw exception:
Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotFoundException: Could not locate the browser window, window name not specified.
Result2 StackTrace:
at Microsoft.VisualStudio.TestTools.UITesting.UITestLogGenerator.GenerateSnapshotInfo(UITestControl control, SnapshotTime time)
at Microsoft.VisualStudio.TestTools.UITesting.UITestLogGenerator.MouseClick(UITestControl control, MouseButtons button, ModifierKeys modifierKeys, MouseActionType mouseActionType, String message)
at Microsoft.VisualStudio.TestTools.UITesting.Mouse.<>c__DisplayClass6.<Click>b__5()
at Microsoft.VisualStudio.TestTools.UITesting.CodedUITestMethodInvoker.InvokeMethod[T](Func`1 function, UITestControl control, Boolean firePlaybackErrorEvent, Boolean logAsAction)
at Microsoft.VisualStudio.TestTools.UITesting.Mouse.Click(UITestControl control, MouseButtons button, ModifierKeys modifierKeys, Point relativeCoordinate)
at Microsoft.VisualStudio.TestTools.UITesting.Mouse.Click(UITestControl control)
at MyFirst.CodedUI2012.TestProject.CodedUITest1.WikiTest() in c:\Users\v-rakong\Documents\Visual Studio 2012\Projects\MyFirst.CodedUI2012.TestProject\MyFirst.CodedUI2012.TestProject\CodedUITest1.cs:line 66

public void WikiTest()
    {
        BrowserWindow.CurrentBrowser = "chrome";//TestContext.DataRow[0].ToString();
        BrowserWindow browser = BrowserWindow.Launch(new Uri("http://www.google.com"));
        browser.Maximized = true;

        HtmlEdit edit = new HtmlEdit(browser);
        edit.SearchProperties.Add(new PropertyExpression(HtmlControl.PropertyNames.Id, "gbqfq", PropertyExpressionOperator.EqualTo));
        edit.Text = "Software Testing";

        HtmlButton search = new HtmlButton(browser);
        search.SearchProperties.Add(HtmlControl.PropertyNames.Id, "gbqfb");
        Mouse.Click(search);

        HtmlHyperlink wiki = new HtmlHyperlink(browser);
        wiki.SearchProperties.Add(new PropertyExpression(HtmlControl.PropertyNames.InnerText, "Wikipedia, the free encyclopedia", PropertyExpressionOperator.Contains));
        Mouse.Click(wiki);

        HtmlHyperlink roles = new HtmlHyperlink(browser);
        try
        {
            roles.SearchProperties.Add(new PropertyExpression(HtmlControl.PropertyNames.InnerText, "Roles", PropertyExpressionOperator.Contains));
            roles.WaitForControlExist(5000);
            Mouse.Click(roles);
        }
        catch
        {
            roles.FilterProperties.Add(new PropertyExpression(HtmlControl.PropertyNames.ControlDefinition, "href=\"#Roles\"", PropertyExpressionOperator.Contains));
            roles.WaitForControlExist(5000);
            Mouse.Click(roles);
        }
    }
Jul 30, 2013 at 1:34 AM
If your using the "Selenium components for Coded UI Cross Browser Testing" from the Visual Studio Gallery, what I've seen from my case is that you need a Name property specified in your search property for the parent window. Your stack trace pretty much said the same thing..."Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotFoundException: Could not locate the browser window, window name not specified."

Although IE is smart enough to go without it, Chrome/FF doesn't seem to be able to search without it. Interesting that you got FF to work...I'm thinking that the gallery extension needs a bug fix.
Coordinator
Jul 30, 2013 at 3:16 AM
Hi rajababuk,

Your question seems related to Microsoft Coded UI Test, but not directly related to CUITe (Coded UI Test enhanced Framework).

You may be better off asking your question in the more appropriate msdn forum here.

Thank you.