This project is read-only.

Chrome GetChildren(), FirstChild casting execption

Feb 7, 2013 at 1:02 AM

I have managed to get my simple test running on Chrome (which is not currently supported?) please refer to my previous thread

When i call the CUITe_HtmlControl.GetChildren() method and ,ICUITe_ControlBase.FirstChild property the following error is thrown
'Microsoft.VisualStudio.TestTools.UITesting.WinControls.WinMenuBar' to type 'Microsoft.VisualStudio.TestTools.UITesting.HtmlControls.HtmlControl'.
   at CUITe.Controls.HtmlControls.CUITe_HtmlControl`1.GetChildren() in c:\Working\codeplex\cuite\CUITe\Controls\HtmlControls\CUITe_HtmlControl.cs:line 193
While i can code around this error i was wondering if anyone would know if its CUITe, Codedui or the cross browser library

I'm not sure where the control type
is coming from especially when called from a div with the following markup <div><ul>...</ul></div>.

Thank you
Feb 7, 2013 at 9:58 AM
Hi QuanEdys,

Thank you for sharing the code for initial support of cross-browser testing with CUITe.

I'm anticipating its inclusion in CUITe soon enough. :)

In regards to the exception being thrown, can you share your test code and more complete html please?

I'm thinking the object whose children are being enumerated is not an html control or maybe there is some type of plug-in within the parent that is causing the issue.

I'm thinking we'd need to update the GetChildren method so that it doesn't always assume the child element is an HtmlControl.

Thank you.
Feb 7, 2013 at 7:39 PM
From further investigation i have found that this happens on both chrome and ff. I believe it is mostly likely the cross browser library. It seem the code is return the window the html is in.

There is a comment on the cross browser library website as followed:
In one of my test I need to get the parent/container of the selected element. I tried using both Container property and GetParent method.

Each of the browser work differently :(
  1. IE - Returns the parent object of the selected element.
  2. Chrome and FF: Are returning the window object.
Any help on this? Is there a way in which I can get the actual parent instead of the window object for FF and Chrome?
So far no one has responded to the comment.

How would you like me to send the code to you?

Thanks again for your help.
Feb 8, 2013 at 12:50 PM
Hi QuanEdys,

I've just checked in some code that works for me with ie and chrome.

Please see the sample tests in .\Sample_CUITeTestProject (NET45)\CrossBrowserHtmlControlTests.cs.

Unfortunately, trying to run it with firefox does not even launch firefox and results in the following exception:

Microsoft.VisualStudio.TestTools.UITest.Extension.UITestException: An error occurred while connecting to Firefox
Result StackTrace:
at Microsoft.VisualStudio.TestTools.UITest.Extension.CrossBrowser.Utility.MapAndReThrow(Exception exception)
at Microsoft.VisualStudio.TestTools.UITest.Extension.CrossBrowser.CrossBrowserService.Launch(Uri uri)
at Microsoft.VisualStudio.TestTools.UITest.Extension.CrossBrowser.CrossBrowserFactory.Launch(Uri uri)
at Microsoft.VisualStudio.TestTools.UITesting.BrowserWindow.LaunchPrivate(Uri uri)
at Microsoft.VisualStudio.TestTools.UITesting.BrowserWindow.<>c__DisplayClass3d.<Launch>b__3c()
at Microsoft.VisualStudio.TestTools.UITesting.CodedUITestMethodInvoker.InvokeMethod[T](Func`1 function, UITestControl control, Boolean firePlaybackErrorEvent, Boolean logAsAction)
at Microsoft.VisualStudio.TestTools.UITesting.BrowserWindow.Launch(Uri uri)
at CUITe.Controls.HtmlControls.CUITe_BrowserWindow.Launch(String url, String title) in c:\Working\codeplex\cuite\CUITe\Controls\HtmlControls\CUITe_BrowserWindow.cs:line 91

I am wondering if you experience the same issue with firefox?

I am running:
Windows 7 Home Premium x64
Visual Studio 2012 Premium Update 1
Visual Studio 2012 Cross Browser Testing Setup for Selenium Components
Internet Explorer 9.0.8112.16421
Firefox 18.0.2
Chrome 24.0.1312.57

Thank you.
Feb 8, 2013 at 6:24 PM

Yes i did get that error.

The reason is because the latest selenium drivers (which is used by the coded UI cross browser library to run in chrome and ff) only supports up to FireFox 17, you will need to downgrade your FireFox version.

Thank you
Feb 10, 2013 at 9:26 PM
FYI Not only does the Microsoft cross browser support code return the wrong heretical information it returns the wrong objects types as well.

for the following HTML
<div id="linktrack-zone-editor" class="cmWidget bestLink">   -> this is my parent div i call GetChildren() on
The return information from the call (i step through the whole heretical list to find it)

WinCustom -> <div> ( this is the div i want)
  WinCustom  ->   <h2>  
       WinEdit Editor's Choice -> (inner <h2> text)
  WinList ->   <ul>