次の方法で共有


UITest Framework – Mozilla Firefox support in VS 2010

Introduction

Test Package for Mozilla Firefox will be a feature pack for Visual Studio 2010 that enables playback of UI actions on a website/web application that have been recorded on Windows Internet Explorer 7 and 8 on Mozilla Firefox web browser. Currently this is in Beta stage and will be released with VS 2010 Feature Pack.

Please note that recording UI actions on Mozilla Firefox is not supported. There is no UICL (UI control Locator) support for controls in Mozilla Firefox. The Benefit of this model is that any recording in IE would playback in Mozilla Firefox without any code change. Even the assertions added through UICL to verify the state/properties of controls need not be changed for validation in Mozilla Firefox. With one time recording in IE, we can playback in IE or Mozilla Firefox any number of times. Thereby all the CodedUITest projects recorded for IE or scenarios recorded in MTM would seamlessly playback in Mozilla Firefox, by just enabling the Mozilla Firefox plugin.

Please take a look at this blog for information related to Record & Playback on IE applications.

 

 

Supported Mozilla Firefox version

This package enables playback of UI actions on the following versions of Mozilla Firefox

· Mozilla Firefox 3.5 and above are supported.

Multiple Version Support

The user could have multiple versions of Mozilla Firefox installed & multiple languages of the same version of Mozilla Firefox installed. The playback provides the user to choose the version & language of Mozilla Firefox on which the playback is supposed to happen. While doing playback using MTM, all the Firefox versions installed on the machine are displayed to the user to choose from. In case of CodedUITest the user can set the BrowserWindow.CurrentBrowser property to any of the installed versions & playback chooses the mentioned Mozilla Firefox version for playback.

Ex: BrowserWindow.CurrentBrowser = “Firefox 3.5.7(ar)” would choose the 3.5.7 Arabic Version of Mozilla Firefox for playback. Setting the CurrentBrowser property to “Firefox” would choose the default version of Mozilla Firefox installed for playback. Check the registry key under HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\Mozilla Firefox to know the names of all the Mozilla Firefox versions installed in your machine and use these names to set the CurrentBrowser property. You can also specify the CurrentBrowser property through CodedUITestCurrentBrowser Environment variable. CUIT would read this environment variable & set the CurrentBrowser property itself as a part of test initialization. This is a better way to choosing browser for playback as it wouldn’t involve changing your CodedUITest & you can manipulate the browser for playback using this environment variable.

 

Supported Visual Studio 2010 SKU’s

This Package is compatible with and can be installed on top of the following SKUs that are available as part Visual Studio:

· Microsoft Visual Studio 2010 Premium and Microsoft Visual Studio 2010 Ultimate (For CodedUI Test)

· Microsoft Visual Studio Test Professional 2010 (For Action Recording)

· Microsoft Visual Studio Agents 2010

 

 

Setup & Configuration

The below msdn article contains all the necessary information to install the setup & how to enable Mozilla Firefox playback in MTM and CodedUITest

https://visualstudiogallery.msdn.microsoft.com/en-us/c7b5accc-abd8-4776-a331-81392a58a3c3 

 

Recording on Mozilla Firefox application controls

For Web Applications we can only record on IE. Recording on Mozilla Firefox is not supported. Any recording in IE would playback in Mozilla Firefox without any code change. Thereby all the CodedUITest projects recorded for IE or scenarios recorded in MTM would seamlessly playback in Mozilla Firefox, by just enabling the Mozilla Firefox plugin.

 

Playback

Playback (or automation) very simply put is all about finding a UI-object based on certain properties (say button named “OK” in a dialog named “Confirmation”) and performing some action on it (say clicking the OK button). Hence there are two parts to this problem “Search” and “Action”.

The general workflow for doing playback in Mozilla Firefox is similar to that of IE. So the concepts & workflows are same for both IE and Mozilla Firefox. If you already know the details of Record and Play of IE application, you can assume that most of them apply to Mozilla Firefox applications also

 

 

Known Issues with Recording in IE and Playback in Mozilla Firefox

Please take a look at this blog for known Issues and troubleshooting tips on IE as most of them apply to Mozilla Firefox also. Since you have to use IE to record actions, it is always good to know how to troubleshoot Record & Play failures in IE

Known Issues in Mozilla Firefox Playback

  1. Editable Div’s : IE has the ability to render editable DIV’s where the user can click inside it & type some content. Mozilla Firefox doesn’t have the ability to render editable DIV’s. Instead it renders as a document inside an IFRAME. When the user records actions on an editable DIV in IE, it fails to playback in Mozilla Firefox as the DIV Tag is not rendered in Mozilla Firefox leading to UITestControlNotFoundException.
  2. DOM Hierarchy Mismatch: Any Web control is identified by a set of intermediate elements in the hierarchy of the DOM tree. These set of intermediate elements form the query id of the control which was discussed in the Recorder section. The Query Id of a control is a string indicating the hierarchy of controls. The Playback uses the query id to find the entire intermediate elements one after other before finding the desired element.
  3. There are instances when the DOM tree’s rendered by the browsers is different. The DOM hierarchy of a control acted upon could be different in IE & Mozilla Firefox. In these cases the playback couldn’t succeed in finding the control in Mozilla Firefox from the information which was recorded in IE.For ex: IE introduces additional FORM or TABLE tags in the hierarchy of the controls which might not be present in case of Mozilla Firefox. In case these tags get captured as intermediate elements during recording; the playback would fail in Mozilla Firefox as the same control wouldn’t have FORM or TABLE tag in its hierarchy.This is not a very common though, but in case you feel if the control you acted upon in present in Mozilla Firefox, but the playback reports that the control cannot be found in Mozilla Firefox, you can compare the DOM hierarchy of the control by viewing the DOM tree’s in IE Developer Toolbar & Firebug.
  4. Playback Action Failure: Some of the controls can be found in Mozilla Firefox, but are not actionable. Whenever the playback has to perform a primitive operation like a click on a control, it has to find the bounding rectangle (location) of the control. For some controls, Mozilla Firefox might return an empty bounding rectangle; thereby even though the search for the control succeeds we cannot perform action on the control. Playback fails with HiddenControlException in these cases.
  5. This is a rare occurrence which was noticed across a few websites. One way to identify this issue is to view the control through firebug. On clicking on a control/Tag in DOM tree, we can see the highlighter which shows the bounding rectangle for the control. If we do not see a bounding rectangle or highlighter for the control, the control is not actionable & the playback would fail with hidden control exception.
  6. Browser Rendering: Many websites take the type of browser into account and send different pages for different types of browsers. In doing so, some websites also modify the properties of the controls being sent. This could result in search failure for controls when we playback in Mozilla Firefox. Using extensions like firebug, IE developer controls we can make sure that the properties of control searched for is consistent across IE & Mozilla Firefox.
  7. Different browser behaviour due to use of Non Standard HTML : Both the browsers IE & Mozilla Firefox support nonstandard HTML to an extent. But some of controls/eventing implemented in a nonstandard way would not work in both the browsers. Due to this reason the action performed on some controls in IE while recording may not work during playback in Mozilla Firefox. This has nothing to do with the Playback but the browser doesn’t support these actions even when it is performed manually. In case of playback failure, make sure that the sequence of actions recorded can be manually performed in Mozilla Firefox.
  8. NavigateToURL aggregator does not support opening the Mozilla Firefox browser with a particular profile. It always open the browser with default profile.

 

Troubleshooting Mozilla Firefox playback failures

Tools for debugging search issues

Most of the exceptions thrown also contain the primary properties of the control on which the playback is being done. We can make use of these properties to search for the control and make sure if it is in an actionable state.

Firebug

Firebug is a handy extension in Mozilla Firefox to inspect HTML and the DOM tree. We can install it from search in the list of Mozilla Firefox extensions. Using it we can search for controls using search properties & inspect it. Pressing F12 brings up the firebug and displays the properties of the page under display in Mozilla Firefox.

For More information on how to use Firebug for debugging specific playback exceptions refer to the section below on ‘Exceptions & what they mean’.

IE Developer Toolbar:

The Internet Explorer Developer Toolbar provides several features for exploring and understanding Web pages. The tool lets you to explore the document object model (DOM) of a Web page. It lets you to locate and select specific elements on a Web page through a variety of techniques.

This tool can be downloaded at

https://www.microsoft.com/downloads/details.aspx?familyid=E59C3964-672D-4511-BB3E-2D5E1DB91038&displaylang=en

In IE8, this toolbar is packaged along with the product. Press ‘F12’ in IE8 to invoke this toolbar.

 

Exceptions & what they mean

Playback on IE or Mozilla Firefox can fail due to various reasons and the playback engine throws the best exception out of a variety of playback exceptions for the user to root cause the reason for the failure.

Recording Failures

Possible Exception

Cause

Comment

TechnologyNotSupportedException

Recoding on a unsupported technology App

If the user tries to record on applications on IE whose version is below 7 or on 64-bit IE or on Mozilla Firefox, the recorder throws a technology supported exception.

Playback failures

Playback does two major things in order to perform action on the control search and action on the control. Following are the possible reasons and their exceptions.

First Rule for troubleshooting Mozilla Firefox playback issues: Whenever there is a playback failure in Mozilla Firefox, do a playback of the same recording on IE. If the playback fails in IE also, follow the troubleshooting tips in the IE user guide located here to root cause the issue. If the playback succeeds in IE but fails in Mozilla Firefox , follow the comments mentioned below depending on the type of exception being thrown.

SearchFailure

Following are some of the suggested tips to debug the search failure during playback.

  • See screenshot (stored in %temp%\uitestlogs\lastrun if logs are enabled) to see whether the control was actually visible or not.
  • Verify the search properties and UI hierarchy (QueryID) using Firebug.

 

Possible Exception

Cause

Comment

UITestControlNotFoundException

The control does not exist or search properties are not enough to find the control.

Use the Firebug tool to see whether the search properties are correct and make sure if the control can be found. If control exists in the Mozilla FireFox document then check whether the DOM hierarchy of the control is same in both IE & Mozilla FireFox. For more information on DOM Hierarchy mismatch refer to 2nd Point in the ‘Known Issues – Issues in Mozilla FireFox Playback’ section.

UITestControlNotAvailableException

The control does not exist in the app now.

Whenever the playback performs an action on a control, it is cached for future references. When the playback tries to act on this cached control which is no longer available, the playback throws this exception.

 
Action Failure

Sometime though the search passes but the playback may not be able to do the action on the control. Following may be the possible reason/tips to debug the issue

  • Verify using Firebug Toolbar whether, is there any other control with the same properties under the parent mentioned in the QueryID. Some time there may be more than one control with the same properties under a parent hence during playback the first control will be selected and the action may fail on it. User can work around it after adding the instance property in the code for the ambiguous control.
  • User can use .DrawHighLight() method to actually see which control is chosen for the UITestAction. This method is available for all the UITestControl and will draw a rectangular highlighter around the control.
  • Verify whether the control state is same as it was during recording e.g., SetValue was recorded on a text box but during playback the text box is read only.

Possible Exception

Cause

Comment/Possible workarounds

ActionNotSupportedOnDisabledControlException

Playback is trying to perform action on a disabled control

This is thrown when the playback try to do some action on the disabled control/read only controls. Following are some of the cases:

· SetValue on a read only combobox/text box

· Click/SetState on disabled buttons/checkboxes

FailedToPerformActionOnHiddenControlException

When the playback tries to act on a control which is present but is not visible

The control cannot be visible when we set the CSS styles of the control to be hidden. The user has to make the control visible before the playback can perform any action on it.

FailedToPerformActionOnBlockedControlException

The control exists but not actionable

Thrown when a control is blocked in this case though the search passes but the required action will not be played back. Following might be some of the causes for this exception

· The control is not visible in the view port and not scrollable even

· Control is blocked due to some modal dialog on top of it

DecodingFailedException

May come in password text box

When the decoding of encrypted password fails due to incorrect key value.

PlaybackFailureException

Default fall back exception for uncategorized issues

For any other failure the playback engine would throw PlaybackFailureException. For example if Get/Set of some property fails for a control playback engine would throw PlaybackFailureException.

Summary

In this blog we have seen the VS 2010 support for Mozilla Firefox browser support for Fast Forward and CodedUITest and how to troubleshoot playback failures in Mozilla Firefox applications.

 

Author – R Praveen

SDET - CodedUITest

Comments

  • Anonymous
    June 21, 2010
    Thanks Praveen, we understand e how codedui working with Mozilla firefox browser and limitaions of UI controls on the Mozilla browser. So, When it will be  available RTM version of  VS2010 Test Package for Mozilla Firefox(plug in feature)  ?

  • Anonymous
    June 21, 2010
    Hi, I am working with VS2010 RTM version on my machine, Currently we are using  "VS2010 Test Package Beta version" for Mozilla Firefox, I am unable to play back using Mozilla FireFox and getting exception like "Unable to perform actions on Mozilla Firefox. Ensure that Visual Studio Test Helper extension for Mozilla Firefox is installed and enabled. Please see the package readme for more details". We did the necessary changes as below. o   Close all instances of Mozilla Firefox o   Run the extension installation tool   ( %CommonProgramFiles%Microsoft SharedVSTT10.0UITestExtensionPackagesConfigFFExtension.exe ) But still we are getting the same exception throwing. "Unable to perform actions on Mozilla Firefox. Ensure that Visual Studio Test Helper extension for Mozilla Firefox is installed and enabled. Please see the package readme for more details". Please let us know, if we have any solution here. Are we need to using RTM verison for  "VS2010 Test Package"???????