Locked CUIT - how to click a radiobutton in a webtable

  • Friday, April 13, 2012 7:35 PM
     
     

    Folks,

    I would like to click a radiobutton which has a dynamic value in a webtalbe. I was able to do it in QTP, but no luck with VS.

     public HtmlRadioButton UIIDradioRadioButton
            {
                get
                {
                    if ((this.mUIIDradioRadioButton == null))
                    {
                        this.mUIIDradioRadioButton = new HtmlRadioButton(this);
                        #region Search Criteria
                        this.mUIIDradioRadioButton.SearchProperties[HtmlRadioButton.PropertyNames.Id] = null;
                        this.mUIIDradioRadioButton.SearchProperties[HtmlRadioButton.PropertyNames.Name] = "IDradio";
                        this.mUIIDradioRadioButton.SearchProperties[HtmlRadioButton.PropertyNames.Value] = "100449";
                        this.mUIIDradioRadioButton.SearchProperties[HtmlRadioButton.PropertyNames.LabeledBy] = null;
                        this.mUIIDradioRadioButton.FilterProperties[HtmlRadioButton.PropertyNames.Title] = null;
                        this.mUIIDradioRadioButton.FilterProperties[HtmlRadioButton.PropertyNames.ItemCount] = "10";
                        this.mUIIDradioRadioButton.FilterProperties[HtmlRadioButton.PropertyNames.Class] = null;
                        this.mUIIDradioRadioButton.FilterProperties[HtmlRadioButton.PropertyNames.ControlDefinition] = "onclick=\"selectID(1,\'Sam Money\', \'";
                        this.mUIIDradioRadioButton.FilterProperties[HtmlRadioButton.PropertyNames.TagInstance] = "3";
                        this.mUIIDradioRadioButton.WindowTitles.Add("Search Account");
                        #endregion
                    }
                    return this.mUIIDradioRadioButton;
                }
            }
           

All Replies

  • Monday, April 16, 2012 9:42 AM
    Moderator
     
     Answered

    Hi Jordan1001,

    As your description, the radiobutton control’s value is dynamic populated then you should comment out the search property line which against this property.

    The Coded UI record engine will always try to generate a group of robust and resilient search condition for the target control, and all of these search properties are against the rendered page of the site, so it doesn’t know which value is dynamic changing.

    In this scenario, I guess it will works fine if you comment out this search property line, if not, please try to change the radiobutton’s research property group to make sure there isn’t any other search property use a property which would dynamic changing.


    Tony Xiao [MSFT]
    MSDN Community Support | Feedback to us

  • Monday, April 16, 2012 2:06 PM
     
     Answered

    Thank you Tony for the tip; I was able to fix the issue and used selectID(1) to select the first radio button in the table. I was able to select the same radiobutton in different environments despite the different value it has.

    that's how the solution would look like:

     public HtmlRadioButton UIIDradioRadioButton
            {
                get
                {
                    if ((this.mUIIDradioRadioButton == null))
                    {
                        this.mUIIDradioRadioButton = new HtmlRadioButton(this);
                        #region Search Criteria
                        this.mUIIDradioRadioButton.SearchProperties[HtmlRadioButton.PropertyNames.Id] = null;
                        this.mUIIDradioRadioButton.FilterProperties[HtmlRadioButton.PropertyNames.ControlDefinition] = "onclick=\"selectID(1)";
                        this.mUIIDradioRadioButton.FilterProperties[HtmlRadioButton.PropertyNames.TagInstance] = "3";
                        this.mUIIDradioRadioButton.WindowTitles.Add("Search Account");
                        #endregion
                    }
                    return this.mUIIDradioRadioButton;
                }
            }


  • Monday, April 16, 2012 3:14 PM
     
     

    Hi,

    You can try to find out the immediate parent of radio button and use it as the container. Or if there is a label associated with the radio buttons you can use it to reach the specific radio button. If you need an example, please share the html page (screenshot and page-source).

    Regards,

    Pankaj


    Utility to run CUIT Ordered Tests for multiple iterations @ http://cuitbatchrunner.codeplex.com/