Coded UI with HTML Form

Html Form Fillup with Coded UI

In this tutorial we will fill Html form like –

Input type – text, radio, checkbox and text area, select

And the sample code will be –

 

[TestInitialize()]
        public void MyTestInitialize()
        {
            BrowserWindow.Launch("http://demo.tanmaysarkar.com/sample_01.html");
        }
[TestMethod]
public void CodedUITestMethod1()
        {
            BrowserWindow Browser = new BrowserWindow();
            Browser.SearchProperties[UITestControl.PropertyNames.Name] = "Automation Sample 1:: Tanmay Sarkar";

            HtmlEdit FirstName = new HtmlEdit(Browser);
            FirstName.SearchProperties[UITestControl.PropertyNames.Name] = "ts_first_name";
            FirstName.Text = "tanmay";

            HtmlEdit LastName = new HtmlEdit(Browser);
            LastName.SearchProperties[UITestControl.PropertyNames.Name] = "ts_last_name";
            LastName.Text = "sarkar";

            HtmlTextArea Address = new HtmlTextArea(Browser);
            Address.SearchProperties[UITestControl.PropertyNames.Name] = "ts_address";
            Address.Text = "Home";
            
            HtmlComboBox Country = new HtmlComboBox(Browser);
            Country.SearchProperties[UITestControl.PropertyNames.Name] = "ts_country";
            Country.SelectedItem = "India";

            HtmlRadioButton GenderMale = new HtmlRadioButton(Browser);
            GenderMale.SearchProperties[UITestControl.PropertyNames.Name] = "ts_gender";
            GenderMale.SearchProperties[HtmlRadioButton.PropertyNames.Value] = "male";
            GenderMale.Selected = true;

            HtmlCheckBox ChkFootball = new HtmlCheckBox(Browser);
            ChkFootball.SearchProperties[UITestControl.PropertyNames.Name] = "ts_checkbox2";
            ChkFootball.SearchProperties[HtmlCheckBox.PropertyNames.Value] = "football";
            ChkFootball.Checked = true;

            HtmlCheckBox ChkHockey = new HtmlCheckBox(Browser);
            ChkHockey.SearchProperties[UITestControl.PropertyNames.Name] = "ts_checkbox1";
            ChkHockey.SearchProperties[HtmlCheckBox.PropertyNames.Value] = "cricket";
            ChkHockey.Checked = true;
        }

Related posts:

Leave a Reply

Your email address will not be published. Required fields are marked *