Friday, June 21, 2013

Finding Objects Dynamically with Coded UI

Mapping objects with visual studios coded UI can be cumbersome and hard to manage one way to make your fame work a little lighter is to make a class that does this for you and even better creating a more generic method that will handle all the objects for you. The way I accomplish this idea is with the following code snippets

   public T  GetControlGeneric<T>(string propertyValue, string property,  PropertyExpressionOperator propertyExpressionOperator = PropertyExpressionOperator.Contains) where T:WinControl
        {
            return GetControlGenericWithParent<T>(propertyValue, property, ThickClient, propertyExpressionOperator);
        }
        public T GetControlGenericWithParent<T>(string propertyValue, string property, UITestControl parent, PropertyExpressionOperator propertyExpressionOperator = PropertyExpressionOperator.Contains)where T:WinControl
        {
            T ctrl = (T)Activator.CreateInstance(typeof(T), new object[] { parent });
            ctrl.SearchProperties.Add(property, propertyValue, propertyExpressionOperator);
            return ctrl;
        }
-Sarah

So you ran a coded UI Teast and Now IE isn't working

If for some reason you start to get the following error when you open IE
and you have recently ran a coded UI test try the following
  1. Got to Internet options
  2. Click on the Connections Tab
  3. Click the lan settings btn
  4. And Uncheck the box "Use a proxy ect"
  5. Try to use IE Again
This should resolve the problem

-Sarah

Thursday, May 2, 2013

So Your Coded UI Stopped Working and You Don't Know Why

If your coded UI test suddenly stopped working (the test can no longer find objects on the screen you keep getting null reference exceptions) your may be a victim of copy local =ture. If some one (or yourself) has been adding or removing the coded UI dlls they may have accidently set copy local to ture. To get you test back up and running you simply flip it back to false.

-Sarah

Thursday, October 25, 2012

Implementing Successful Automation Solutions

A couple of weeks ago I was asked to give a quick talk on implementing successful Automation solutions. I tried to come up with something that didn't talk to our solution or tool but more to our experience. Here is the outline of that quick talk. 

The Three Mile Stones
  • Gaining Support
  • Gaining Traction 
  • Maintaining 
 Gaining Support
  • Create a solution that becomes a integral part of your comany's software processes. 
  • Create a several quick wins (the lowest hanging fruit with the most benefit). 
  • Be very visible and open with everything you are doing. 
  • Don't spend a long time developing a large framework. 
 Gaining Traction
  • Instead of trying to tackle a back log which can put you in a perpetual state of "Working on the back log" draw a line and work along side the developers on the new feature moving forward with them and picking off the back log only  when you have down time or extra resources. 
 Maintaining
  • Run test nightly or weekly. 
  • Dedicate time out of each week to maintain your suite. 
  • Don't let the test sit untouched over a development cycle. 

-Sarah

Friday, June 22, 2012

Iterating through a Html Table



Some of the more common testing we do involves comparing a list of data on the page to a list of expected data from the db. I like to using the following code snippet to accomplish it.
1: for (int i = 0; i < DbTable.Rows.Count;i++ )
2: {
3: for (int j = 0; j < DbTable.Columns.Count; j++)
4: {
5: DataRow dbRrow = DbTable.Rows[i];
6: HtmlCell cellRow = new HtmlCell(contentTable);
7: cellRow.FilterProperties[HtmlCell.PropertyNames.RowIndex] = i.ToString();
8: cellRow.FilterProperties[HtmlCell.PropertyNames.ColumnIndex] = j.ToString();
9: if (!cellRow.FriendlyName.Contains(dbRrow[j].ToString()))
10: {
11: _error += dbRrow[j].ToString() + " did not match " + cellRow.FriendlyName;
12: }
13: }
14: }


In the inner loop you can always offset the row and column if you have a check box in your table or maybe an image you don't want to Compare on. -Sarah