Sunday 26 October 2014

CodedUI for CrossBrowser testing


For testing any web application, it would naturally be best to test it with all of the most popular browsers.
It’s easy to feel like you’re doing the same thing over and over again. What works in one browser doesn’t always work in other browsers. As a result, you end up in testing every single feature on all the major browsers that easily multiplies the time required for QA. Manually testing cross browser is time consuming and tedious process that is inefficient and conflicts with Today’s short development cycles. Hence the functional automation written once should be liable to run in all supporting browsers
In this post, I’ll demonstrate how this problem might be resolved in a simple way by creating coded UI test cases that will execute against any modern browser, using only C#.
Coded UI, inbuilt supports Internet Explorer.
To run the same functional tests in other browsers using Coded UI tests against Chrome or Firefox using the Selenium cross-browser plugin and this is how you do it

1. Download the Cross-browser plugin for Coded UI Test that uses Selenium to run tests against Chrome and Firefox from here: Selenium cross-Browser plugin
image

2.  After installing the Cross-Browser testing installer, verify that
Microsoft.VisualStudio.TestTools.UITest.Extension.CrossBrowserProxy.dll
is found in the following location :
“%ProgramFiles%\Common Files\microsoft shared\VSTT\Cross BrowserSelenium Components” (for 32 bit machines)
“%ProgramFiles(x86)%\Common Files\microsoft shared\VSTT\Cross BrowserSelenium Components” (for 64 bit machines)
  • Make sure to have all these file in the above mentioned path :
    3
3. Record a Coded UI test in IE
image


image

4. Change the browser to run the same test against Chrome using the BrowserWindow object i.e.
BrowserWindow.CurrentBrowser = "Chrome";   //For Chrome
BrowserWindow.CurrentBrowser = "FireFox";   //For Chrome
image

Web browsers evolve continuously and you may not realize when this happens. Sometimes this means certain features aren’t available in the new browser version, which in turn causes some tests to fail, even if they were passed previously. That’s why it’s important to disable automatic browser updates and wait until the new version is supported by the Selenium components for Coded UI Cross-Browser Testing. Otherwise, unexpected exceptions might occur during run time.

Note:
  • Currently, Coded UI supports Firefox 25.0.1 version
  • Chrome 21 Plus version
  • IE9 /IE10/IE11
  • Apple Safari is not supported
  • The action of starting the web browser must be part of Coded UI Test. If you have a web browser already open and you want to run test on it, the playback will fail  unless you are using Internet explorer. Therefore it is a best practice to include the startup of browser as part of Coded UI Tests.

No comments:

Post a Comment