Bringing you news, technical articles, and other useful content about Visual Studio ALM and Team Foundation Server
More videos »
Microsoft Visual Studio 2012 provides complete record and play support through Coded UI for performing UI validations on Sharepoint 2010 applications.
Recording and playing back on a sharepoint application is no different from recording on any webpage on Internet Explorer as internally the Coded UI IE plugin is being used. This blog assumes that you are familiar with Coded UI Tests and know how to record, generate code and play it back. For further details on how to achieve the same, please take a look at the link provided.
While all actions recorded on Sharepoint 2010 should playback seamlessly, this blog enumerates a few minor workarounds that you may need for achieving the same.
1. Working with Excel on SharePoint 2010
With Visual Studio 2012, you can now record actions, generate code and play it back on Office 2010 controls within SharePoint 2010 as well. If you’re working on enabling automation for Office 2010 web parts then there are a few points to keep in mind.
Working with Excel, there are some limitations but they can be worked around by making minor changes in the code:-
If you are recording actions on an empty cell, then this action can be handcoded by double clicking on the cell and then performing a set text operation. This is needed because a click on the cell, followed by any keyboard action essentially activates the textarea within the cell. Simply recording a setvalue on the empty cell would search for the textarea which is in fact not present until the cell is clicked on. If you record a click followed by a setvalue, changing the Click to a DoubleClick in the generated code should do the trick.
If you are recording on a non-empty cell, then it gets a little more complicated, this is because the moment you add text to a cell, a new <div> control gets added as a child of the cell which contains the text entered. The recorder records actions on the div which, before the text gets entered, doesn’t exist. In case case, follow the below steps:-
2. Find the "HtmlDiv" child of this cell, you can use “InnerText” and “Class” properties for this.
private UITestControlgetControlToDoubleClick(HtmlCell cell)
if (String.IsNullOrEmpty(cell.InnerText)) return cell;
HtmlDiv pane = new HtmlDiv(cell);
// Class is an important property in finding pane
UITestControlCollection panes =pane.FindMatchingControls();
3. Code Double-click on HtmlDiv. ( Eg: Mouse.DoubleClick(uIItemPane, new Point(31, 14)); )
4. SetText on TextArea. (Eg: uIGridKeyboardInputEdit.Text = value; } )
Known Issue:- Trying to record an action where we set some value to any cell, followed by an arrow key to navigate will fail to playback correctly.
2. Recording actions on Visio\PowerPoint controls
Recording on Visio\PowerPoint controls is currently not supported.
3. SharePoint Silverlight Controls
If your SharePoint application contains Silverlight web parts then the approach to test the same is slightly different. Visual Studio 2012 itself does not support Silverlight testing, but you can install a Silverlight plugin from VS Gallery to test the same.
Steps involved in setting up your machine for testing Silverlight Web parts in Sharepoint 2010:-
With this your machine setup is done. To start testing on any Silverlight application, all you need to do is this:-
For more details on how Recording on Silverlight controls work, you can refer to the following:-
Fanstatic blog post for sharepointer how me