コード例 #1
0
ファイル: IEElement.cs プロジェクト: glennneiger/openrpa
 public IEElement(Browser browser, mshtml.IHTMLElement Element)
 {
     Browser    = browser;
     RawElement = Element;
     className  = Element.className;
     id         = Element.id;
     tagName    = Element.tagName.ToLower();
     if (tagName == "input")
     {
         mshtml.IHTMLInputElement inputelement = Element as mshtml.IHTMLInputElement;
         type = inputelement.type.ToLower();
     }
     try
     {
         mshtml.IHTMLUniqueName id = RawElement as mshtml.IHTMLUniqueName;
         uniqueID = id.uniqueID;
     }
     catch (Exception)
     {
     }
     IndexInParent = -1;
     if (Element.parentElement != null && !string.IsNullOrEmpty(uniqueID))
     {
         mshtml.IHTMLElementCollection children = Element.parentElement.children;
         for (int i = 0; i < children.length; i++)
         {
             mshtml.IHTMLUniqueName id = children.item(i) as mshtml.IHTMLUniqueName;
             if (id != null && id.uniqueID == uniqueID)
             {
                 IndexInParent = i; break;
             }
         }
     }
 }
コード例 #2
0
ファイル: Plugin.cs プロジェクト: lig7711/openrpa
        private void OnMouseUp(InputEventArgs e)
        {
            var thread = new Thread(new ThreadStart(() =>
            {
                Log.Debug(string.Format("IE.Recording::OnMouseUp::begin"));
                var re = new RecordEvent(); re.Button = e.Button;
                var a  = new GetElement {
                    DisplayName = (e.Element.Name).Replace(Environment.NewLine, "").Trim()
                };

                var browser     = new Browser(e.Element.RawElement);
                var htmlelement = browser.ElementFromPoint(e.X, e.Y);
                if (htmlelement == null)
                {
                    return;
                }

                var sw = new System.Diagnostics.Stopwatch();
                sw.Start();
                IESelector sel = null;
                // sel = new IESelector(e.Element.rawElement, null, true);
                GenericTools.RunUI(() =>
                {
                    sel = new IESelector(browser, htmlelement, null, false, e.X, e.Y);
                });
                if (sel == null)
                {
                    return;
                }
                if (sel.Count < 2)
                {
                    return;
                }
                a.Selector   = sel.ToString();
                a.Image      = sel.Last().Element.ImageString();
                re.UIElement = e.Element;
                re.Element   = new IEElement(browser, htmlelement);
                re.Selector  = sel;
                re.X         = e.X;
                re.Y         = e.Y;

                Log.Debug(e.Element.SupportInput + " / " + e.Element.ControlType);
                re.a = new GetElementResult(a);
                if (htmlelement.tagName.ToLower() == "input" && htmlelement.tagName.ToLower() == "select")
                {
                    mshtml.IHTMLInputElement inputelement = (mshtml.IHTMLInputElement)htmlelement;
                    re.SupportInput = (inputelement.type.ToLower() == "text" || inputelement.type.ToLower() == "password");
                }

                Log.Debug(string.Format("IE.Recording::OnMouseUp::end {0:mm\\:ss\\.fff}", sw.Elapsed));
                OnUserAction?.Invoke(this, re);
            }));

            thread.IsBackground = true;
            thread.Start();
        }
コード例 #3
0
        public bool parseUserAction(ref IRecordEvent e)
        {
            if (e.UIElement == null)
            {
                return(false);
            }
            if (e.UIElement.ProcessId < 1)
            {
                return(false);
            }
            var p = System.Diagnostics.Process.GetProcessById(e.UIElement.ProcessId);

            if (p.ProcessName != "iexplore" && p.ProcessName != "iexplore.exe")
            {
                return(false);
            }

            var browser = new Browser(e.UIElement.rawElement);


            var htmlelement = browser.ElementFromPoint(e.X, e.Y);

            if (htmlelement == null)
            {
                return(false);
            }

            var selector = new IESelector(htmlelement, null, browser.Document, false);

            var a = new GetElement {
                DisplayName = htmlelement.id + "-" + htmlelement.tagName + "-" + htmlelement.className
            };

            a.Selector = selector.ToString();


            var tagName = htmlelement.tagName;

            if (string.IsNullOrEmpty(tagName))
            {
                tagName = "";
            }
            tagName = tagName.ToLower();
            e.a     = new GetElementResult(a);
            if (tagName == "input")
            {
                mshtml.IHTMLInputElement inputelement = (mshtml.IHTMLInputElement)htmlelement;
                e.SupportInput = (inputelement.type.ToLower() == "text" || inputelement.type.ToLower() == "password");
            }

            return(true);
        }
コード例 #4
0
        public Form1()
        {
            InitializeComponent();

            string site  = "google.com";
            string form  = "f";
            string field = "q";

            webBrowser1.Navigate(site);

            while (webBrowser1.ReadyState != WebBrowserReadyState.Complete)
            {
                Application.DoEvents();
                System.Threading.Thread.Sleep(50);
            }

            if (webBrowser1.Document == null)
            {
                MessageBox.Show("ERROR: Возможно отсутствует интерет");
                return;
            }

            mshtml.IHTMLDocument2 doc = (mshtml.IHTMLDocument2)webBrowser1.Document.DomDocument;

            mshtml.HTMLFormElement f = doc.forms.item(form, null);

            if (f == null)
            {
                MessageBox.Show(string.Format("ERROR: форма с именем \"{0}\" не найдена", form));
                return;
            }

            mshtml.IHTMLInputElement fld = f.namedItem(field);

            if (fld == null)
            {
                MessageBox.Show(string.Format("ERROR: поле формы с именем \"{0}\" не найдено", field));
                return;
            }

            string query = "hello world";

            fld.value = query;

            f.submit();
        }
コード例 #5
0
 private void DoSubmit(HtmlElement element)
 {
     if (element == null)
     {
         return;
     }
     if (element.TagName.ToLower().Equals("form"))
     {
         mshtml.IHTMLFormElement ielement = (mshtml.IHTMLFormElement)element.DomElement;
         ielement.submit();
     }
     if (element.TagName.ToLower().Equals("input"))
     {
         mshtml.IHTMLInputElement input = (mshtml.IHTMLInputElement)element.DomElement;
         mshtml.IHTMLFormElement  form  = input.form;
         if (form != null)
         {
             form.submit();
         }
     }
     DoSubmit(element.Parent);
 }
コード例 #6
0
 private void DoSubmit()
 {
     logger.Debug("submit element: {0}", OuterHtml);
     if (underlying.TagName.ToLower().Equals("input"))
     {
         mshtml.IHTMLInputElement input = (mshtml.IHTMLInputElement)underlying.DomElement;
         mshtml.IHTMLFormElement  form  = input.form;
         if (form != null)
         {
             form.submit();
         }
         else
         {
             string type = underlying.GetAttribute("type").ToLower();
             if (type != null && ("submit".Equals(type) || "image".Equals(type)))
             {
                 ((mshtml.IHTMLElement)input).click();
             }
         }
     }
     DoSubmit(underlying);
 }
コード例 #7
0
        private void webBrowser1_LoadCompleted(object sender, NavigationEventArgs e)
        {
            if (i == 0)
            {
                mshtml.HTMLDocument document = (mshtml.HTMLDocument)webBrowser1.Document;
                var elems = document.getElementsByName("commit");
                foreach (mshtml.IHTMLElement button in elems)
                {
                    mshtml.IHTMLElement k = button;
                    k.click();
                    i = 1;
                }
                webBrowser1.Navigate("https://www.supremenewyork.com/checkout");
            }
            else if (i == 1)
            {
                mshtml.HTMLDocument      document2 = (mshtml.HTMLDocument)webBrowser1.Document;
                mshtml.IHTMLInputElement input     = (mshtml.IHTMLInputElement)document2.getElementById("order_billing_name");
                input.value = name_textbox.Text;

                input       = (mshtml.IHTMLInputElement)document2.getElementById("order_email");
                input.value = email_textbox.Text;

                input       = (mshtml.IHTMLInputElement)document2.getElementById("order_tel");
                input.value = tel_textbox.Text;

                input       = (mshtml.IHTMLInputElement)document2.getElementById("bo");
                input.value = add1_textbox.Text;

                input       = (mshtml.IHTMLInputElement)document2.getElementById("oba3");
                input.value = add2_textbox.Text;

                input       = (mshtml.IHTMLInputElement)document2.getElementById("order_billing_zip");
                input.value = zip_textbox.Text;

                input       = (mshtml.IHTMLInputElement)document2.getElementById("order_billing_city");
                input.value = city_textbox.Text;

                input       = (mshtml.IHTMLInputElement)document2.getElementById("cnb");
                input.value = number_textbox.Text;

                input       = (mshtml.IHTMLInputElement)document2.getElementById("vval");
                input.value = cvv_textbox.Text;

                mshtml.IHTMLSelectElement select = (mshtml.IHTMLSelectElement)document2.getElementById("order_billing_state");
                select.value = state_combobox.Text;

                select = (mshtml.IHTMLSelectElement)document2.getElementById("credit_card_type");
                if (type_combobox.Text == "Visa")
                {
                    select.value = "visa";
                }
                if (type_combobox.Text == "American Express")
                {
                    select.value = "american_express";
                }
                if (type_combobox.Text == "Master Card")
                {
                    select.value = "master";
                }

                select       = (mshtml.IHTMLSelectElement)document2.getElementById("credit_card_month");
                select.value = month_combobox.Text;

                select       = (mshtml.IHTMLSelectElement)document2.getElementById("credit_card_year");
                select.value = year_combobox.Text;

                var elems = document2.getElementsByName("order[terms]");
                foreach (mshtml.IHTMLElement button in elems)
                {
                    mshtml.IHTMLElement k = button;
                    k.click();
                }

                elems = document2.getElementsByName("commit");
                foreach (mshtml.IHTMLElement button in elems)
                {
                    mshtml.IHTMLElement k = button;
                    k.click();
                }

                i = 2;
            }
        }
コード例 #8
0
 public static void SetValue(this HtmlElement element, string value)
 {
     mshtml.IHTMLInputElement input = (mshtml.IHTMLInputElement)element.DomElement;
     input.value = value;
 }
コード例 #9
0
        void AddTestStep(HtmlElement element, String elementXPosition, String elementYPosition)
        {
            stepsList.SelectionBullet = true;
            WebBrowser browser = new WebBrowser();

            if (tabControl2.SelectedIndex == 0)
            {
                browser = webBrowser1;
            }
            else
            {
                browser = webBrowser2;
            }

            //on, in, to
            String intent = "on";

            //value of input field
            var inputValue = "";

            // value of select list
            var selectValue = "";

            // Check what type of element has been selected
            var elementType = "";

            switch (element.TagName.ToLower())
            {
            case "input":
                elementType = "input field";
                intent      = "in";
                try
                {
                    mshtml.IHTMLInputElement input = element.DomElement as mshtml.IHTMLInputElement;
                    inputValue = input.value;
                }
                catch { }

                break;

            case "select":
                elementType = "select list";
                intent      = "on";
                try
                {
                    mshtml.IHTMLSelectElement select = element.DomElement as mshtml.IHTMLSelectElement;
                    mshtml.HTMLOptionElement  option = (mshtml.HTMLOptionElement)select.item(select.selectedIndex, null);
                    if (select.selectedIndex != 0)
                    {
                        selectValue = option.text;
                    }
                }
                catch { }
                break;

            case "a":
                elementType = "link";
                intent      = "on";
                break;

            case "button":
                intent      = "on";
                elementType = "Button";
                break;

            case "img":
                intent      = "on";
                elementType = "Slide";
                break;
            }

            // Check if the selected element has an associated label we can use
            var elementLabel = "";
            var labels       = browser.Document.GetElementsByTagName("label");

            foreach (HtmlElement lbl in labels)
            {
                //check if element has an ID so we can obtain a label for it
                if (element.Id != null)
                {
                    //check if the current label for attribute matches one for our element
                    //@'for=\"name"'
                    String forLabel = lbl.OuterHtml.Replace("\"", "");
                    if (forLabel.Contains("for=" + element.Id))
                    {
                        elementLabel = lbl.OuterText;
                    }
                }
            }

            //get image alt text
            // vScreen products use images for slides!!
            if (elementType == "Slide")
            {
                mshtml.IHTMLImgElement img = element.DomElement as mshtml.IHTMLImgElement;
                //GenerateAndAddExpectedTextStep(elementType, img.alt, elementYPosition, elementXPosition);


                //BUG: Currently outputs i.e. **USER** even if we're not recording a valid action
                if (outputUser == true)
                {
                    stepsList.SelectionBullet = false;
                    //record which user is recording an action
                    stepsList.AppendText("**" + user.ToUpper() + "**" + Environment.NewLine);
                    //we only want to record the user when recording a new list of steps before an expected result
                    outputUser = false;
                }
                stepsList.SelectionBullet = true;
                stepsList.AppendText(string.Format("Click {0} '{1}' {2}{4}", intent, img.alt, elementType, user.ToUpper(), Environment.NewLine));
            }

            // get text for link
            if (elementType == "link")
            {
                elementLabel = element.InnerText;
                intent       = "on";
            }

            // check if we're dealing with a an input button/submit/reset
            if (elementType == "input field" && elementLabel == "")
            {
                try
                {
                    mshtml.IHTMLInputButtonElement button = element.DomElement as mshtml.IHTMLInputButtonElement;
                    elementType  = "button";
                    intent       = "on";
                    elementLabel = button.value;
                    if (elementLabel == null)
                    {
                        elementLabel = button.name;
                    }
                }
                catch (Exception ex)
                {
                    intent      = "in";
                    elementType = "input";
                }
            }

            if (element.TagName == "BUTTON")
            {
                mshtml.IHTMLElement button = element.DomElement as mshtml.IHTMLElement;


                //BUG: Currently outputs i.e. **USER** even if we're not recording a valid action
                if (outputUser == true)
                {
                    stepsList.SelectionBullet = false;
                    //record which user is recording an action
                    stepsList.AppendText("**" + user.ToUpper() + "**" + Environment.NewLine);
                    //we only want to record the user when recording a new list of steps before an expected result
                    outputUser = false;
                }
                stepsList.SelectionBullet = true;
                stepsList.AppendText(string.Format("Click {0} '{1}' {2}{4}", intent, button.innerHTML, elementType, user.ToUpper(), Environment.NewLine));
            }

            //check type of input
            if (element.TagName == "SELECT")
            {
                if (!string.IsNullOrWhiteSpace(selectValue))
                {
                    //BUG: Currently outputs i.e. **USER** even if we're not recording a valid action
                    if (outputUser == true)
                    {
                        stepsList.SelectionBullet = false;
                        //record which user is recording an action
                        stepsList.AppendText("**" + user.ToUpper() + "**" + Environment.NewLine);
                        //we only want to record the user when recording a new list of steps before an expected result
                        outputUser = false;
                    }
                    stepsList.SelectionBullet = true;
                    stepsList.AppendText(string.Format("Select '{0}'{2}", selectValue, user.ToUpper(), Environment.NewLine));
                }
                else
                {
                    //BUG: Currently outputs i.e. **USER** even if we're not recording a valid action
                    if (outputUser == true)
                    {
                        stepsList.SelectionBullet = false;
                        //record which user is recording an action
                        stepsList.AppendText("**" + user.ToUpper() + "**" + Environment.NewLine);
                        //we only want to record the user when recording a new list of steps before an expected result
                        outputUser = false;
                    }
                    stepsList.SelectionBullet = true;
                    if (RecordElementPosition == true)
                    {
                        // we found the label associated to the selected input and it doesn't have a value input
                        stepsList.AppendText(string.Format("Click {0} '{1}' {2} toward {4} {5} of page{6}", intent, elementLabel, elementType, user.ToUpper(), elementYPosition, elementXPosition, Environment.NewLine));
                    }
                    else
                    {
                        // we found the label associated to the selected input and it doesn't have a value input
                        stepsList.AppendText(string.Format("Click {0} '{1}' {2}{4}", intent, elementLabel, elementType, user.ToUpper(), Environment.NewLine));
                    }
                }
            }
            else
            {
                //check if input has a value
                if (string.IsNullOrWhiteSpace(inputValue))
                {
                    if (!string.IsNullOrWhiteSpace(elementLabel) && !string.IsNullOrWhiteSpace(elementType))
                    {
                        //BUG: Currently outputs i.e. **USER** even if we're not recording a valid action
                        if (outputUser == true)
                        {
                            stepsList.SelectionBullet = false;
                            //record which user is recording an action
                            stepsList.AppendText("**" + user.ToUpper() + "**" + Environment.NewLine);
                            //we only want to record the user when recording a new list of steps before an expected result
                            outputUser = false;
                        }

                        stepsList.SelectionBullet = true;
                        if (RecordElementPosition == true)
                        {
                            // we found the label associated to the selected input and it doesn't have a value input
                            stepsList.AppendText(string.Format("Click {0} '{1}' {2} toward {4} {5} of page{6}", intent, elementLabel, elementType, user.ToUpper(), elementYPosition, elementXPosition, Environment.NewLine));
                            //stepsList.AppendText(string.Format("**{3}**{6}Click {0} '{1}' {2} toward {4} {5} of page{6}", intent, elementLabel, elementType, user.ToUpper(), elementYPosition, elementXPosition, Environment.NewLine));
                        }
                        else
                        {
                            // we found the label associated to the selected input and it doesn't have a value input
                            stepsList.AppendText(string.Format("Click {0} '{1}' {2}{4}", intent, elementLabel, elementType, user.ToUpper(), Environment.NewLine));
                            //stepsList.AppendText(string.Format("**{3}**{4}Click {0} '{1}' {2}{4}", intent, elementLabel, elementType, user.ToUpper(), Environment.NewLine));
                        }
                    }
                }
                else
                {
                    if (elementType == "button")
                    {
                        //BUG: Currently outputs i.e. **USER** even if we're not recording a valid action
                        if (outputUser == true)
                        {
                            stepsList.SelectionBullet = false;
                            //record which user is recording an action
                            stepsList.AppendText("**" + user.ToUpper() + "**" + Environment.NewLine);
                            //we only want to record the user when recording a new list of steps before an expected result
                            outputUser = false;
                        }
                        stepsList.SelectionBullet = true;
                        if (RecordElementPosition == true)
                        {
                            // we found the label associated to the selected input and it doesn't have a value input
                            stepsList.AppendText(string.Format("Click {0} '{1}' {2} toward {4} {5} of page{6}", intent, elementLabel, elementType, user.ToUpper(), elementYPosition, elementXPosition, Environment.NewLine));
                        }
                        else
                        {
                            // we found the label associated to the selected input and it doesn't have a value input
                            stepsList.AppendText(string.Format("Click {0} '{1}' {2}{4}", intent, elementLabel, elementType, user.ToUpper(), Environment.NewLine));
                        }
                    }
                    else
                    {
                        //BUG: Currently outputs i.e. **USER** even if we're not recording a valid action
                        if (outputUser == true)
                        {
                            stepsList.SelectionBullet = false;
                            //record which user is recording an action
                            stepsList.AppendText("**" + user.ToUpper() + "**" + Environment.NewLine);
                            //we only want to record the user when recording a new list of steps before an expected result
                            outputUser = false;
                        }
                        stepsList.SelectionBullet = true;
                        // we found the label associated to the selected input
                        stepsList.AppendText(string.Format("Input '{0}'{2}", inputValue, user.ToUpper(), Environment.NewLine));
                    }
                }
            }

            stepsList.SelectionBullet = false;
            ScrollToRecordedStepsEnd();
        }
コード例 #10
0
        void AddExpectedResult(HtmlElement element, String elementXPosition, String elementYPosition)
        {
            // whether or not to output the actor in the test steps script
            outputUser = true;

            //ensure bullet list for new line is off for expected result
            stepsList.SelectionBullet = false;

            //check which browser window is recording the result
            WebBrowser browser = new WebBrowser();

            if (tabControl2.SelectedIndex == 0)
            {
                browser = webBrowser1;
            }
            else
            {
                browser = webBrowser2;
            }

            var elementType = "";

            switch (element.TagName.ToLower())
            {
            case "a":
                elementType = "Link";
                GenerateAndAddExpectedTextStep(elementType, element.InnerText, elementYPosition, elementXPosition);
                break;

            case "h1":
                elementType = "page heading";
                GenerateAndAddExpectedTextStep(elementType, element.InnerText, elementYPosition, elementXPosition);
                break;

            case "h2":
                elementType = "page heading";
                GenerateAndAddExpectedTextStep(elementType, element.InnerText, elementYPosition, elementXPosition);
                break;

            case "h3":
                elementType = "page heading";
                GenerateAndAddExpectedTextStep(elementType, element.InnerText, elementYPosition, elementXPosition);
                break;

            case "h4":
                elementType = "page heading";
                GenerateAndAddExpectedTextStep(elementType, element.InnerText, elementYPosition, elementXPosition);
                break;

            case "h5":
                elementType = "page heading";
                GenerateAndAddExpectedTextStep(elementType, element.InnerText, elementYPosition, elementXPosition);
                break;

            case "h6":
                elementType = "page heading";
                GenerateAndAddExpectedTextStep(elementType, element.InnerText, elementYPosition, elementXPosition);
                break;

            case "p":
                elementType = "page text";
                GenerateAndAddExpectedTextStep(elementType, element.InnerText, elementYPosition, elementXPosition);
                break;

            case "span":
                elementType = "page";
                GenerateAndAddExpectedTextStep(elementType, element.InnerText, elementYPosition, elementXPosition);
                break;

            case "label":
                elementType = "Label";
                GenerateAndAddExpectedTextStep(elementType, element.InnerText, elementYPosition, elementXPosition);
                break;

            case "div":
                elementType = "page text";
                GenerateAndAddExpectedTextStep(elementType, element.InnerText, elementYPosition, elementXPosition);
                break;


            case "img":
                elementType = "Image";
                mshtml.IHTMLImgElement img = element.DomElement as mshtml.IHTMLImgElement;
                GenerateAndAddExpectedTextStep(elementType, img.alt, elementYPosition, elementXPosition);
                break;

            case "input":
                //check if regular input or a button!
                try
                {
                    mshtml.IHTMLInputElement input = element.DomElement as mshtml.IHTMLInputElement;
                    if (input.type.ToLower() == "text")
                    {
                        elementType = "Input";

                        // Check if the selected element has an associated label we can use
                        var inputLabel  = "";
                        var inputLabels = browser.Document.GetElementsByTagName("label");
                        foreach (HtmlElement lbl in inputLabels)
                        {
                            //check if element has an ID so we can obtain a label for it
                            if (element.Id != null)
                            {
                                //check if the current label for attribute matches one for our element
                                String forLabel = lbl.OuterHtml.Replace("\"", "");
                                if (forLabel.Contains("for=" + element.Id))
                                {
                                    inputLabel = lbl.OuterText;
                                }
                            }
                        }

                        string inputValue = "";
                        if (input.value == null)
                        {
                            inputValue = input.name;
                        }
                        else
                        {
                            inputValue = input.value;
                        }

                        if (RecordElementPosition == true)
                        {
                            stepsList.AppendText(string.Format("{5}Expected Result{5}'{6} {0}' {1} toward {3} {4} of page contains text '{2}'{5}{5}", inputLabel, elementType, inputValue, elementYPosition, elementXPosition, Environment.NewLine, user));
                        }
                        else
                        {
                            stepsList.AppendText(string.Format("{3}Expected Result{3}{4} '{0}' {1} contains text '{2}'{3}{3}", inputLabel, elementType, inputValue, Environment.NewLine, user));
                        }
                    }

                    else
                    {
                        elementType = "Button";
                        mshtml.IHTMLInputButtonElement inputButton = element.DomElement as mshtml.IHTMLInputButtonElement;

                        //need to clean up - check if field is a password field!
                        if (input.type.ToLower() == "password")
                        {
                            elementType = "Input";
                        }



                        // Check if the selected element has an associated label we can use
                        var inputLabel  = "";
                        var inputLabels = browser.Document.GetElementsByTagName("label");
                        foreach (HtmlElement lbl in inputLabels)
                        {
                            //check if element has an ID so we can obtain a label for it
                            if (element.Id != null)
                            {
                                //check if the current label for attribute matches one for our element
                                String forLabel = lbl.OuterHtml.Replace("\"", "");
                                if (forLabel.Contains("for=" + element.Id))
                                {
                                    inputLabel = lbl.OuterText;
                                }
                            }
                        }

                        string inputValue = "";
                        if (input.value == null)
                        {
                            inputValue = input.name;
                        }
                        else
                        {
                            inputValue = input.value;
                        }
                        if (RecordElementPosition == true)
                        {
                            stepsList.AppendText(string.Format("{4}Expected Result{4}{5} {0} toward {2} {3} of page contains text '{1}'{4}{4}", elementType, inputValue, elementYPosition, elementXPosition, Environment.NewLine, user.ToUpper()));
                        }
                        else
                        {
                            //    stepsList.AppendText(string.Format("Expected Result{2}{3} {0} contains text '{1}'{2}{2}", elementType, inputValue, Environment.NewLine, user));
                            if (inputLabel == "")
                            {
                                inputLabel = input.name;
                            }
                            stepsList.AppendText(string.Format("{3}Expected Result{3}{4} '{0}' {1} contains text '{2}'{3}{3}", inputLabel, elementType, inputValue, Environment.NewLine, user));
                        }
                    }
                }
                catch { }

                elementType = "Input";
                break;

            case "button":
                elementType = "Button";
                mshtml.IHTMLElement button = element.DomElement as mshtml.IHTMLElement;
                if (RecordElementPosition == true)
                {
                    stepsList.AppendText(string.Format("{4}Expected Result{4}{5} {0} toward {2} {3} of page contains text '{1}'{4}{4}", elementType, button.innerHTML, elementYPosition, elementXPosition, Environment.NewLine, user));
                }
                else
                {
                    stepsList.AppendText(string.Format("{2}Expected Result{2}{3} {0} contains text '{1}'{2}{2}", elementType, button.innerHTML, Environment.NewLine, user));
                }
                break;

            case "select":
                elementType = "Select list";
                mshtml.IHTMLSelectElement select = element.DomElement as mshtml.IHTMLSelectElement;
                mshtml.HTMLOptionElement  option = (mshtml.HTMLOptionElement)select.item(select.selectedIndex, null);

                // use select list associated label name
                // Check if the selected element has an associated label we can use
                var elementLabel = "";
                var labels       = browser.Document.GetElementsByTagName("label");
                foreach (HtmlElement lbl in labels)
                {
                    //check if element has an ID so we can obtain a label for it
                    if (element.Id != null)
                    {
                        //check if the current label for attribute matches one for our element
                        String forLabel = lbl.OuterHtml.Replace("\"", "");
                        if (forLabel.Contains("for=" + element.Id))
                        {
                            elementLabel = lbl.OuterText;
                        }
                    }
                }

                var selectValue = "";
                if (select.selectedIndex != 0)
                {
                    selectValue = option.text;
                }
                if (selectValue != "")
                {
                    if (RecordElementPosition == true)
                    {
                        stepsList.AppendText(string.Format("{5}Expected Result{5}{6} '{0}' {1} toward {3} {4} of page contains option '{2}'{5}{5}", elementLabel, elementType, selectValue, elementYPosition, elementXPosition, Environment.NewLine, user));
                        stepsList.AppendText("\n");
                    }
                    else
                    {
                        stepsList.AppendText(string.Format("{3}Expected Result{3}{4} '{0}' {1} contains option '{2}'{3}{3}", elementLabel, elementType, selectValue, Environment.NewLine, user));
                        stepsList.AppendText("\n");
                    }
                }
                break;
            }
            ScrollToRecordedStepsEnd();
        }