VS2010 Coded UI Tests

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.
PT GuyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LearnedCommented:
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
PT GuyAuthor Commented:
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
Bob LearnedCommented:
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
Bob LearnedCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PT GuyAuthor Commented:
I was able to find and alter the address after expanding and looking through all of the code
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.