Introducing Cross Browser Testing with Coded UI Tests
October 30, 2012
Coded UI Tests help automate browser based applications built on Internet Explorer. We are now enabling cross-browser testing of such applications. Users will be able to perform functional testing of web applications across IE/Firefox/Chrome. One can use IE to record tests and validate control properties using Coded UI Test Builder. Users also have an option to hand code cross browser tests. If user needs to playback on IE, she can click on Run All in Test Explorer which plays back the recording using Coded UI inbuilt IE Plugin. On the other hand, if the user needs to playback on non-IE browser, she can set BrowserWindow.CurrentBrowser as “firefox” or “chrome” in the test depending on which browser she wants to test before running from the test explorer. In this case, Coded UI Engine communicates with Selenium Web Driver to execute the playback.
Hope you like this feature. Feel free to drop your feedback here
System Requirements:
- Operating System: Windows 8 X86 Client/Windows 8 X64/Win7 X64/Win7 X86/Win2k8 R2 SP1
- IE version – IE9/ classic IE10
- Firefox version – 15+
- Chrome version – 21+
- Visual Studio Ultimate/Premium – VS 2012 RTM + VS 2012 Update 1
- Selenium NET Bindings and the Selenium ChromeDriver made available to you through an installer on Visual Studio Gallery. Refer to the file attachment “CUIT Cross Browser Testing Acquisition” for more details
Features:
The following features are available across the various web browsers:
- Recording support for actions and validation on supported IE browsers
- Hand-coding scenarios support for such things as control properties, search, and playback waiters.
- Support for popups and dialog
- Ability to execute basic JavaScript with no return type
- Search resilience (via smart match) and performance improvements
Scenario Videos:
Record on IE and Playback everywhere
Author cross browser tests with Coded UI Test Builder
Author cross browser tests using plain hand coding without UI Map
Run cross browser tests sequentially on multiple browsers
Troubleshoot cross browser test failures
Known Limitations
- No support for Safari browser
- Browser launch needs to be part of the UITest. In case you have a browser already open and you want to run steps on the opened browser, playback will fail for non-IE browser windows. Hence, it is advisable to have launch too as part of the test case.
- Automating browser based actions such as Maximize/minimize/restore is not supported
Troubleshooting tips
Enable HTML Logger – follow http://msdn.microsoft.com/en-us/library/jj159363.aspx
Feedback Survey:
Please fill in the survey to register your feedback on this feature: https://s.zoomerang.com/s/CrossBrowserTesting. Your feedback will help us plan for further enhancement to the cross browser feature.
Hello
I have a different situation here. My application supports only Google Chrome , dev team developed this application like that and will not able to open in any other browsers. Now I am looking to automate this application. I tried to identify the objects through Coded UI test builder and I could see same properties for all controls. Even I tried to record and play back with Chrome. When I recorded all controls have been created with control type as “Document”. Is there a way to automate an application which supports only Chrome either hand coded or record and play back? Please suggest me..
@infovenu: You would not be able to record on Chrome as recording support for this feature is available only for the above mentioned versions of IE. Hence, Coded UI Test Builder does not work fine on other browsers. However, if you want to hand code on Chrome, you can use the Chrome Developer Tools (can be accessed by F12) to inspect properties of controls. You can then use these properties to add Search Properties in your code.
Hi,
The link provided for feedback survey seems to be dead. I am getting Page not found error (Http 400 Bad Request).
Regards,
Pankaj
Hello.
I'm trying to run Codedui tests in chrome. Here is the code i'm using:
BrowserWindow.CurrentBrowser = "chrome";
var browser = BrowserWindow.Launch(new Uri("http://msdn.com"));
But i'm getting exception: "The browser chrome is currently not supported".
I have VS2012 Ultimate and 'Selenium components for Coded UI Cross Browser Testing' installed.
Am I doing something wrong or is there smthing i need to check?
Hello!
I did following:
– installed VS 2012 premium, vsupdate_KB2707250.exe and CodedUITestCrossBrowserSetup.msi on Server 2012 . – downloaded chrome driver and selenium dot net bindings, unzipped these files and copied to folder as specified.
– created new Coded UI project and recorded several actions in IE 10.
– Run test on IE (it was executed successfully).
– Added BrowserWindow.CurrentBrowser = “firefox”; and run the test – test was failed with error:
Unable to find browser window with 'Security Settings at Risk' in the title.
Result StackTrace: at Microsoft.VisualStudio.TestTools.UITest.Extension.CrossBrowser.CrossBrowserFactory.Locate(PropertyExpressionCollection searchProperties, PropertyExpressionCollection filterProperties)
The same is for Chrome. Please help me with this issue.
I cannot hear the recordings. What do I need to download to listen?
Will this feature work without CTP update, by just installing Selenium components on VSTS 2010 Ultimate RTM.
Or it is mandatory to install the CTP update for this to run on chrome?
Alexey_R:
The problem is the window title. When the framework is search for the browser window to play back in it starts by looking at the window title which is added as a property when you recorded this. I had some issues with this but it's easily soved. Go to the .uitest file and edit the window title to match what is actually showing.
Likely, when you recorded on IE some security settings were upsetting IE so it displayed that on the title but when you play back in Chrome it does not complain but shows the correct title but now the framework is looking for the title with the security warning, not the correct one.
Hope that helps
@Peter: Thanks for the solution that you suggested. I hope it helps solve Alexy_R's problem. We are planning to add smart match for changing window titles in the next release. Hopefully, it will ease the problem
@Alexy_R: You do not need to download Selenium separately. The installer that you download from Visual Studio Gallery visualstudiogallery.msdn.microsoft.com/…/CodedUITestCrossBrowserSetup.msi should install all required components for you
Also, in case the solution suggested by Peter does not work, write to us with problem description and HTML Logs as well as UITestLogs at shubhram at microsoft dot com
I have a problem getting this to run on Firefox. It works fine on IE and Chrome but when I try Firefox I get the following:
Result Message:
Test method Med3K.Framework.WebFramework.Sanity.Smoke threw exception:
Microsoft.VisualStudio.TestTools.UITest.Extension.UITestException: No response from server for url http://localhost:7055/hub/session/b0d7759e-4327-479e-a787-0885dfa6bae9/element/%7B4ade158a-2728-4140-9693-9f6eb79182d1%7D/displayed
and I have no idea what is wrong. I'm using Firefox 17.0 and Chrome 23.0 using scripts recorded on IE9. I'm running VS2012 Premium with the latest updates and everything installed as described above.
The curious thing is that it doesn't fail immediately, the script starts up, launched Firefox, logs in to the application but then when it tries to interact with the webpage nothing happens for 2 minutes and then I get this failure message.
Any ideas?
@Peter Harlid:
Does the page take a really long time to load? After the login step, if you catch the UITestException and try to move ahead does that work? If that does not, write to us with problem description and HTML Logs as well as UITestLogs at shubhram at microsoft dot com. (Or skhan at microsoft dot com)
Coded UI test work only in IE!!!WTF why visual studio can't find controls and class of elements in firefox and chrome? My environment VS 2012 premium, vsupdate_KB2707250.exe
@ch_mn,
There isn't any audio associated with these videos.
Awesome article Shubhra, and thanks for Chrome & Firefox playback testing, do you know you guys will support Safari? 🙂
Currently , My team is embedded in TFS 2010. Is it possible for this. Does this Patch will work in TSF 2010.
Does this work with Firefox version 17?
Does this work if I record an action recording in MTM 2012 and need to playback against Chrome?
Very good blog post!!!
After test execution, the chrome driver never close, so it cause a lot of instance of chrome driver open on test box. Is there any way to close the driver after test execution
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?
Awesome idea, thanks for the blog.
I have found it a little hard to get test written in IE to work with chrome and have been trying another framework on top of this (CUITe) which, while doesn't support VS2012 or this feature, they work amazingly well together.
Thanks again
I'm having the same problem as Utk, when running in firefox or Chrome. When calling method like GetChildren() the wrong children objects are returned – when calling GetChildren() on a div in the following situation: <div><ul>..</ul></div> i get:
HtmlDiv linktrack-zone-editor
WinMenuBar System
WinMenuItem System
WinMenu System
WinMenuItem Restore
WinMenuItem Move
WinMenuItem Size
WinMenuItem Minimize
WinMenuItem Maximize
WinSeparator
WinMenuItem Close Alt+F4
WinTitleBar BBC – Search results for richard 3rd – Mozilla Fir…
WinButton IME
WinButton Minimize
WinButton Restore
WinButton Context help
WinButton Close
WinMenuBar Application
WinControl BBC – Search results for richard 3rd – Mozilla Fir…
<cut the next 400 lines>
Is there anywhere we can download the Cross Browser dll (Microsoft.VisualStudio.TestTools.UITest.Extension.CrossBrowser.dll) so i can step though and see if it's the Selenium WebDriver or this extension getting the wrong information.
It appears to require vs2012 to be installed on test agents? that's a pretty heavy requirement (only got not supported exceptions without it installed).
Now Firefox will open, but I need to update the driver to support FF 18.
Chrome gives me an exception – System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
Recording in Windows 8 + IE10 seems to have a few issues – firstly I don't believe the Action Filters are working with the new start screen (or the run dialog). I ended up pinning IE10 to my taskbar to fix this issue.
IE10 seems to see textboxes as HtmlCustom not HtmlEdit, whereas IE9 appears to be the other way around. This makes it very hard to create a test that works in both browsers.
Hi,
I have followed all the pre-requisite and have install VSTS2012 with Update-1 and Selenium components for Coded UI Cross Browser Testing. Also verified the browser version too.
But when launch the test case to run in Chrome by adding BrowserWindow.CurrentBrowser= 'Chrome'; in my code it did not invoked the chrome browser.
Have i missed out any configuration or pre-requisite ?
I recorded my script on IE9, can I playback on IE8 and IE10 using remote desktop and can I run sequentially?
Hi,
I have follow this guide and i keep getting the error when running the test in firefox. It open firefox but cannot go to the url… In IE and chrome it work only firefox..
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)
I have VSTS 2012 update 4 RC & selenium components installed.
I am able to run test in Chrome & firefox for few steps. But there is a scenario that new chrome window opens on clicking on one control. Then I need to continue the steps in the new active chrome window.
But Codeduitest failed to recognize the controls present in the new active Chrome window. Below is the exception error message:
element not visible
(Session info: chrome=30.0.1599.101)
(Driver info: chromedriver=2.2,platform=Windows NT 6.1 x86_64)
I suspect it's unable to read the htmldocument of the new active chrome/firefox window. While debugging i found that BrowserWindow still refers to the intial window instead of connecting to the latest new window opened by the code.
Please do the needfull to resolve this issue.
say i have 1000 test cases i have to launch the non ie browser 1000 times one each test? That looks very awkward to do.
can you please clarify?
can this work for Visual Studio 2010
Hi All,
In my case Latest version of Firefox is supported while it is creating problem for google chrome.
I have google chrome Version 32.0.1700.102. but Coded Ui Builder is not able to detect controls in google chrome.Can u suggest what to do to run Coded Ui in Google chrome.
Any suggestion is welcome..
I am not able to view videos. Please can anybody help or suggest me about how to view the videos here…
Hi Shubhra Maji,
I am currently using VSTS 2013 and I want to test my application on Chrome. The steps I performed are same as that of the video shared above.
Step 1: I followed all the mentioned steps for Downloading "Selenium component for Chrome driver"
Step 2: I then recorded my test on IE 11.
Step 3: When I tried to play back on Chrome (Latest Version 37), the test fails stating below error.
Result Message:
Test method Automation1.CodedUI_Tests.CodedUITest1.CodedUITestMethod1 threw exception:
Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotFoundException: Unable to find the top level element of the control —> Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotFoundException: Unable to find browser window with 'Amazon.com Sign In' in the title.
But the first problem I could sense here is there isn't any chrome browser started. By referring the video
I could understand that a command prompt window opens when the selected test is Run.
Please assist me on this as its very urgent for me to proceed further on writing my own Coded UI tests.
Regards
Nazeer
Shubhra Hi and thanks for the article.
Is the fact that Coded UI Engine communicates with Selenium Web Driver can solve the missing support SAFARI browser?
(Our product is working on IE, Safari, Opera, FireFox, Chrome. I'm trying to find a solution that will help me create auto-tests for all browsers.)
When will the following limitation be resolved? This is a pretty bad limitation 🙁
Browser launch needs to be part of the UITest. In case you have a browser already open and you want to run steps on the opened browser, playback will fail for non-IE browser windows. Hence, it is advisable to have launch too as part of the test case.
Hi,
Was support of frames in Chrome tested? Coded UI is not able to perform any action on control located inside frame. Works fine in IE but does not in Chrome.
Has anyone tested a frame based UI in Chrome with Coded UI?
Thank you!
Olena
Test Name: CodedUITestMethod1
Test FullName: crossbrowser1.Test2.CodedUITestMethod1
Test Source: c:dolTFSMadhucrossbrowser1Test2.cs : line 27
Test Outcome: Failed
Test Duration: 0:00:00.82174
Result Message:
Test method crossbrowser1.Test2.CodedUITestMethod1 threw exception:
Microsoft.VisualStudio.TestTools.UITest.Extension.UITestException: The playback engine could not find the Selenium binaries required to run cross browser coded UI tests. This may be because the Selenium .NET bindings and Selenium Chrome driver are not installed or an older version of the Selenium Components Installer was used. For more information about installing the binaries, see go.microsoft.com/fwlink
Result StackTrace:
at Microsoft.VisualStudio.TestTools.UITest.Extension.CrossBrowser.CrossBrowserFactory.CheckSeleniumComponents(String browserName)
at Microsoft.VisualStudio.TestTools.UITest.Extension.CrossBrowser.CrossBrowserFactory.GetBrowserSupportLevel(String browserName)
at Microsoft.VisualStudio.TestTools.UITest.Framework.BrowserPluginManager.GetBrowserFactoryByName(String browserName)
at Microsoft.VisualStudio.TestTools.UITesting.BrowserWindow.SetCurrentBrowserWindowPrivate(String value)
at Microsoft.VisualStudio.TestTools.UITesting.BrowserWindow.<>c__DisplayClass46.<set_CurrentBrowser>b__45()
at Microsoft.VisualStudio.TestTools.UITesting.CodedUITestMethodInvoker.InvokeMethod[T](Func`1 function, UITestControl control, Boolean firePlaybackErrorEvent, Boolean logAsAction)
at Microsoft.VisualStudio.TestTools.UITesting.BrowserWindow.set_CurrentBrowser(String value)
at crossbrowser1.Test2.CodedUITestMethod1() in c:dolTFSMadhucrossbrowser1Test2.cs:line 30
I did all Steps , while executing it throws error. is it required any dll reference adding or any manual steps to execute.
I got this error
Test Name: CodedUITestMethod1
Test FullName: crossbrowser1.Test2.CodedUITestMethod1
Test Source: c:dolTFSMadhucrossbrowser1Test2.cs : line 27
Test Outcome: Failed
Test Duration: 0:00:00.82174
Result Message:
Test method crossbrowser1.Test2.CodedUITestMethod1 threw exception:
Microsoft.VisualStudio.TestTools.UITest.Extension.UITestException: The playback engine could not find the Selenium binaries required to run cross browser coded UI tests. This may be because the Selenium .NET bindings and Selenium Chrome driver are not installed or an older version of the Selenium Components Installer was used. For more information about installing the binaries, see go.microsoft.com/fwlink
Result StackTrace:
is it Client Software on Machine "Firefox",Chrome and IE11 installed in Client machine
Hi All,
I am not able to execute coded ui test on Chrome and Firefox browsers.
Chrome Version : 43.0
Firefox Version : 31.0
Test are executed correctly on IE 9 browser. Can someone help me?
Error:
Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotFoundException: The playback failed to find the control with the given search properties. Additional Details:
TechnologyName: 'Web'
ControlType: 'Custom'
Id: 'frmLogon'
TagName: 'FORM'
—> System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component.
Result StackTrace:
at Microsoft.VisualStudio.TestTools.UITest.Playback.Engine.IScreenElement.FindAllDescendants(String bstrQueryId, Object& pvarResKeys, Int32 cResKeys, Int32 nMaxDepth)
at Microsoft.VisualStudio.TestTools.UITest.Playback.ScreenElement.FindAllScreenElement(String queryId, Int32 depth, Boolean singleQueryId, Boolean throwException, Boolean resetSkipStep)
at Microsoft.VisualStudio.TestTools.UITest.Playback.ScreenElement.FindScreenElement(String queryId, Int32 depth, Boolean resetSkipStep)
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.FindFirstDescendant(String queryId, Int32 maxDepth, Int32& timeLeft)
TRES BIEN JE TROUVE DE JOUR EN JOUR BON COURAGE ?ET BONNE CHANCE
Hi,
I am getting below exception while executing the script on Chrome:
An Exception of type 'System.InvalidOperationException' occurred in WebDriver.dll
but was not handled in user code
Additional information: chrome not reachable
(Driver info: chromedriver=2.8.241075, platform =Windows NT6.3…….
Please suggest how to resolve this issue.
Regards,
Ankur Kumar
Hi All,
my dev team developed a website for flight service and I am supposed to automate it using Coded UI. I tried to automate using coded in chrome after installing selenium components and including BrowserWindown.current = "chrome",
when i playback the test, the chrome browser is opened but no test were performed. Kindly help to resolve this issue. searched many website but unable to find the way to playback in chrome.
Hi,
Coded UI tests run in IE and in Chrome. But Firefox browser does not start. Tried with latest Firefox version (and with older versions). No Success.
Is there requirement for running Firefox browser from the Coded UI project?
Thanks in advance!
Olena
A little update. I was able to run coded ui tests few times in Firefox 33 (made few changes to the browser settings and to profiles, not sure though what exactly was done). This old version seems to be the highest supported version.
After reinstalling Firefox test do not start again.
Unbelievable that 1) the test execution engine is to sensitive to the certain setup of the browser and 2) it is quite difficult to find a help about this on internet.
Hi
I have some queries. Assume user1 is logged in using chrome browser and simultaneously user2 is logged in using IE. Presently control in in IE. Now I am able to move the control to chrome through coded ui and c# code. But I am unable to perform any actions (Ex: clicking, entering text in text boxes etc……..) I heard that it's not possible to do so using coded ui. If anybody knows, please reply how t do it.
Hi naveen are u able to execute test script on chrome browser. Please help us by providing the code that u used for chrome browser using coded ui.
Thanks in advance
You have links to “author cross browser tests…” That is my situation. We can’t record in IE and then run in Chrome. Our web application does not run in IE. So, I am looking for resources on how to hand code for Chrome. Your videos appear to address that need, but they are on skydrive, which our company security policies will not allow us to access. Is this content somewhere else where I can see it.