[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

VS2010 Coded UI Tests

Posted on 2010-04-06
5
Medium Priority
?
1,497 Views
Last Modified: 2013-11-27
I am playing around with the Coded UI test and I'm wondering if there's a way to change the web address of the website that I recorded after performing the recording. For instance, I have several servers that I want to apply the same test across without having to keep performing the same tests over and over.
0
Comment
Question by:PT Guy
  • 3
  • 2
5 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 30043568
I haven't worked with the Coded UI tests very much, so I don't have an answer, but I am trying to get up to speed on what VS.NET 2010 brings to the table.  I would love to help you, but I need to get to the same place that you are.  What steps did you take to create the Coded UI test?
0
 

Author Comment

by:PT Guy
ID: 30052990
It was a simple point and click test of link functionality of a website. Created the UI test in order to do things like change the site address, and particular variables of the test
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 30058284
I recorded a simple web page test with Gmail, and I got this:


       public void RecordedMethod1()
        {
            #region Variable Declarations
            WinButton uIGmailButton = this.UIGoogleMicrosoftInterWindow.UILinksToolBar.UIGmailButton;
            HtmlSpan uIP7Pane = this.UIGoogleMicrosoftInterWindow.UIMainFrame.UIHttpsmailgooglecommaDocument.UIP7Pane;
            #endregion

            // Click 'Gmail' button
            Mouse.Click(uIGmailButton, new Point(32, 7));

            // Click ':p7' pane
            Mouse.Click(uIP7Pane, new Point(127, 7));
        }

Open in new window

0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 30058442
It generated some UI helper classes. I could see some places where you could add some code to use variables, instead of hard-coded values.
[GeneratedCode("Coded UITest Builder", "10.0.30319.1")]
    public class UIGoogleMicrosoftInterWindow : BrowserWindow
    {
        
        public UIGoogleMicrosoftInterWindow()
        {
            #region Search Criteria
            this.SearchProperties[UITestControl.PropertyNames.Name] = "Google";
            this.SearchProperties[UITestControl.PropertyNames.ClassName] = "IEFrame";
            this.WindowTitles.Add("Google");
                    "mail - Microsoft Internet Explorer provided by");
            #endregion
        }
        
        public void LaunchUrl(System.Uri url)
        {
            this.CopyFrom(BrowserWindow.Launch(url));
        }
        
        #region Properties
        public UILinksToolBar UILinksToolBar
        {
            get
            {
                if ((this.mUILinksToolBar == null))
                {
                    this.mUILinksToolBar = new UILinksToolBar(this);
                }
                return this.mUILinksToolBar;
            }
        }
        
        public UIMainFrame UIMainFrame
        {
            get
            {
                if ((this.mUIMainFrame == null))
                {
                    this.mUIMainFrame = new UIMainFrame(this);
                }
                return this.mUIMainFrame;
            }
        }
        #endregion
        
        #region Fields
        private UILinksToolBar mUILinksToolBar;
        
        private UIMainFrame mUIMainFrame;
        #endregion
    }
    
    [GeneratedCode("Coded UITest Builder", "10.0.30319.1")]
    public class UILinksToolBar : WinToolBar
    {
        
        public UILinksToolBar(UITestControl searchLimitContainer) : 
                base(searchLimitContainer)
        {
            #region Search Criteria
            this.SearchProperties[WinToolBar.PropertyNames.Name] = "Links";
            this.WindowTitles.Add("Google");
            #endregion
        }
        
        #region Properties
        public WinButton UIGmailButton
        {
            get
            {
                if ((this.mUIGmailButton == null))
                {
                    this.mUIGmailButton = new WinButton(this);
                    #region Search Criteria
                    this.mUIGmailButton.SearchProperties[WinButton.PropertyNames.Name] = "Gmail";
                    this.mUIGmailButton.WindowTitles.Add("Google");
                    #endregion
                }
                return this.mUIGmailButton;
            }
        }
        #endregion
        
        #region Fields
        private WinButton mUIGmailButton;
        #endregion
    }
    
    [GeneratedCode("Coded UITest Builder", "10.0.30319.1")]
    public class UIMainFrame : HtmlIFrame
    {
        
        public UIMainFrame(UITestControl searchLimitContainer) : 
                base(searchLimitContainer)
        {
            #region Search Criteria
            this.SearchProperties[HtmlFrame.PropertyNames.Id] = "canvas_frame";
            this.SearchProperties[HtmlFrame.PropertyNames.Name] = "c18nbjdttumy1h";
            this.FilterProperties[HtmlFrame.PropertyNames.AbsolutePath] = null;
            this.FilterProperties[HtmlFrame.PropertyNames.PageUrl] = "?ui=2&view=bsp&ver=1qygpcgurkovy";
            this.FilterProperties[HtmlFrame.PropertyNames.Title] = "main";
            this.FilterProperties[HtmlFrame.PropertyNames.Class] = "cO";
            this.FilterProperties[HtmlFrame.PropertyNames.ControlDefinition] = "class=cO id=canvas_frame title=main name";
            this.FilterProperties[HtmlFrame.PropertyNames.TagInstance] = "4";
            #endregion
        }
        
        #region Properties
        public UIHttpsmailgooglecommaDocument UIHttpsmailgooglecommaDocument
        {
            get
            {
                if ((this.mUIHttpsmailgooglecommaDocument == null))
                {
                    this.mUIHttpsmailgooglecommaDocument = new UIHttpsmailgooglecommaDocument(this);
                }
                return this.mUIHttpsmailgooglecommaDocument;
            }
        }
        #endregion
        
        #region Fields
        private UIHttpsmailgooglecommaDocument mUIHttpsmailgooglecommaDocument;
        #endregion
    }
    
    [GeneratedCode("Coded UITest Builder", "10.0.30319.1")]
    public class UIHttpsmailgooglecommaDocument : HtmlDocument
    {
        
        public UIHttpsmailgooglecommaDocument(UITestControl searchLimitContainer) : 
                base(searchLimitContainer)
        {
            #region Search Criteria
            this.SearchProperties[HtmlDocument.PropertyNames.Id] = null;
            this.SearchProperties[HtmlDocument.PropertyNames.RedirectingPage] = "False";
            this.SearchProperties[HtmlDocument.PropertyNames.FrameDocument] = "True";
            this.FilterProperties[HtmlDocument.PropertyNames.Title] = null;
            this.FilterProperties[HtmlDocument.PropertyNames.AbsolutePath] = "/mail/";
            this.FilterProperties[HtmlDocument.PropertyNames.PageUrl] = "https://mail.google.com/mail/?ui=2&view=bsp&ver=1qygpcgurkovy";
            #endregion
        }
        
        #region Properties
        public HtmlSpan UIP7Pane
        {
            get
            {
                if ((this.mUIP7Pane == null))
                {
                    this.mUIP7Pane = new HtmlSpan(this);
                    #region Search Criteria
                    this.mUIP7Pane.SearchProperties[HtmlDiv.PropertyNames.Id] = ":p7";
                    this.mUIP7Pane.SearchProperties[HtmlDiv.PropertyNames.Name] = null;
                    this.mUIP7Pane.FilterProperties[HtmlDiv.PropertyNames.InnerText] = "Comment Added: De-reference a struct in ";
                    this.mUIP7Pane.FilterProperties[HtmlDiv.PropertyNames.Title] = null;
                    this.mUIP7Pane.FilterProperties[HtmlDiv.PropertyNames.Class] = null;
                    this.mUIP7Pane.FilterProperties[HtmlDiv.PropertyNames.ControlDefinition] = "id=:p7";
                    this.mUIP7Pane.FilterProperties[HtmlDiv.PropertyNames.TagInstance] = "38";
                    #endregion
                }
                return this.mUIP7Pane;
            }
        }
        #endregion
        
        #region Fields
        private HtmlSpan mUIP7Pane;
        #endregion
    }

Open in new window

0
 

Author Comment

by:PT Guy
ID: 31305328
I was able to find and alter the address after expanding and looking through all of the code
0

Featured Post

[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…

607 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question