Friday 1 June 2012

parameterising a form with text and dropdown controls:

 Scenario:

I have a form that have 2 text boxes and one drop down with 6 values to select from, I have parameterise the text boxes to take values from a CSV file but how can i do this for a dropdown

 solution:

you can try the following way :


         //Method to select item
        public void SelectItem1(string Item)
        {
            #region Variable Declarations
            HtmlComboBox uIItemComboBox = this.UIDellTheOfficialSiteDWindow.UIDellTheOfficialSiteDDocument.UISelfrmCustom.UIItemComboBox;
            #endregion
            // Select 'Japan' in 'Unknown Name' combo box
            uIItemComboBox.SelectedItem = Item;
        }

Calling this in your CodedUITest1.cs  like
             string Item = TestContext.DataRow["Item"].ToString();              this.UIMap.SelectItem1(Item);

This is a small example to select the dropdown item from the CSV file, You can tweak it as per your requirement.

 

No comments:

Post a Comment