/// <summary>
        /// </summary>
        /// <param name="webElementType"></param>
        /// <param name="context">Context within which to search for the element.</param>
        /// <param name="by">The locating mechanism to use.</param>
        /// <param name="elementDescription"></param>
        /// <param name="frameIndex">Zero-based index of the frame in which to find the element.</param>
        /// <returns></returns>
        /// <exception cref="NotFoundException">Thrown when element cannot be found. </exception>
        /// <exception cref="NoSuchFrameException">If the frame with index specified in <paramref name="frameIndex"/>cannot be found.</exception>
        protected IEnumerable <string> GetAllOptionsText(WebElementType webElementType, ISearchContext context, By @by, string elementDescription, int frameIndex)
        {
            var element = GetElementOrThrow(context, @by, elementDescription, frameIndex);
            var text    = element.GetAllOptionsText(webElementType).ToList();

            WriteInfoLogEntry(ConstructDataFetchedMessage(text, elementDescription));
            return(text);
        }
        /// <summary>
        /// </summary>
        /// <param name="webElementType"></param>
        /// <param name="by">The locating mechanism to use.</param>
        /// <param name="elementDescription"></param>
        /// <param name="frameIndex">Zero-based index of the frame in which to find the element.</param>
        /// <returns></returns>
        /// <exception cref="NotFoundException">Thrown when element cannot be found. </exception>
        /// <exception cref="NoSuchFrameException">If the frame with index specified in <paramref name="frameIndex"/>cannot be found.</exception>
        protected string GetSelectedText(WebElementType webElementType, By @by, string elementDescription, int frameIndex)
        {
            var element = GetElementOrThrow(@by, elementDescription, frameIndex);
            var text    = element.GetSelectedText(webElementType);

            WriteInfoLogEntry(ConstructDataFetchedMessage(text, elementDescription));
            return(text);
        }
        /// <summary>
        /// </summary>
        /// <param name="webElementType"></param>
        /// <param name="context">Context within which to search for the element.</param>
        /// <param name="by">The locating mechanism to use.</param>
        /// <param name="elementDescription"></param>
        /// <param name="value"></param>
        /// <param name="frameIndex">Zero-based index of the frame in which to find the element.</param>
        /// <exception cref="NotFoundException">Thrown when element cannot be found. </exception>
        /// <exception cref="NoSuchFrameException">If the frame with index specified in <paramref name="frameIndex"/>cannot be found.</exception>
        /// <exception cref="UnexpectedTagNameException">Thrown when the element wrapped is not a &lt;select&gt; element.</exception>
        /// <exception cref="NoSuchElementException">Thrown if there is no element with the given text present.</exception>
        protected void SelectByText(WebElementType webElementType, ISearchContext context, By @by, string elementDescription, string value, int frameIndex)
        {
            switch (webElementType)
            {
            case WebElementType.HtmlCombo:
            {
                var element = GetElementOrThrow(context, @by, elementDescription, frameIndex);
                new SelectElement(element).SelectByText(value);
                break;
            }

            case WebElementType.JQueryCombo:
            {
                var element2 = GetElementOrThrow(context, By.Id(string.Concat(GetId(@by, elementDescription), "_input")), _associatedElementDesc(elementDescription, "input"), frameIndex);
                element2.EnterValue(value);
                element2.SendKeys(Keys.ArrowDown + Keys.Enter);
                break;
            }
            }
            WriteInfoLogEntry(ConstructDataSelectedMessage(value, elementDescription));
        }
        /// <summary>
        /// Returns the selected option text from a combobox
        /// </summary>
        /// <param name="webElement"></param>
        /// <param name="webElementType">The type of the element (Html or Jquery)</param>
        /// <returns></returns>
        public static string GetSelectedText(this IWebElement webElement, WebElementType webElementType)
        {
            var    driver     = ((IWrapsDriver)webElement).WrappedDriver;
            var    jsExecutor = (IJavaScriptExecutor)driver;
            string text       = null;

            switch (webElementType)
            {
            case WebElementType.HtmlCombo:
            {
                text = new SelectElement(webElement).SelectedOption.GetText();
                break;
            }

            case WebElementType.JQueryCombo:
            {
                text = (string)jsExecutor.ExecuteScript("return arguments[0].options[arguments[0].selectedIndex].text;", webElement);
                break;
            }
            }
            return(text);
        }
        /// <summary>
        /// Finds checkbox element using specified location strategy with given context, unticks if it is already ticked and logs the action.
        /// </summary>
        /// <param name="webElementType"></param>
        /// <param name="context">Context within which to search for the element.</param>
        /// <param name="by">The locating mechanism to use.</param>
        /// <param name="elementDescription">Element description to use in exception and log messages.</param>
        /// <param name="frameIndex">Zero-based index of the frame in which to find the element.</param>
        /// <exception cref="NoSuchFrameException">If the frame with index specified in <paramref name="frameIndex"/>cannot be found.</exception>
        /// <exception cref="NotFoundException">Thrown when element cannot be found. </exception>
        /// <exception cref="StaleElementReferenceException">Thrown when the target element is no longer valid in the document DOM.</exception>
        /// <exception cref="ElementNotVisibleException">Thrown when the target element is not visible.</exception>
        protected void Untick(WebElementType webElementType, ISearchContext context, By @by, string elementDescription, int frameIndex)
        {
            var checkbox = GetElementOrThrow(context, @by, elementDescription, frameIndex);

            switch (webElementType)
            {
            case WebElementType.HtmlCheckbox:
            {
                checkbox.Untick();
                SwitchToDefaultContent();
                break;
            }

            case WebElementType.JQueryCheckbox:
            {
                var accompanyingLabel = _LabelAccompanyingCheckbox(@by, elementDescription, frameIndex);
                checkbox.Untick(accompanyingLabel);
                SwitchToDefaultContent();
                break;
            }
            }
            WriteInfoLogEntry(ConstructCheckboxClickedMessage(elementDescription, false));
        }
        /// <summary>
        /// Returns the text of all options from a combobox
        /// </summary>
        /// <param name="webElement"></param>
        /// <param name="webElementType"></param>
        /// <returns>An IEnumerable with text of all options in the combobox</returns>
        public static IEnumerable <string> GetAllOptionsText(this IWebElement webElement, WebElementType webElementType)
        {
            var driver                = ((IWrapsDriver)webElement).WrappedDriver;
            var jsExecutor            = (IJavaScriptExecutor)driver;
            IEnumerable <string> text = null;

            switch (webElementType)
            {
            case WebElementType.HtmlCombo:
            {
                var allOptions = new SelectElement(webElement).Options;
                text = allOptions.Select(option => option.GetText());
                break;
            }

            case WebElementType.JQueryCombo:
            {
                IEnumerable <object> textObjects = (ReadOnlyCollection <object>)
                                                   jsExecutor.ExecuteScript("var optionTexts = [];" +
                                                                            "var options = arguments[0].options;" +
                                                                            "for(var i = 0; i < options.length; i++)" +
                                                                            "{" +
                                                                            "optionTexts.push(options[i].text);" +
                                                                            "}" +
                                                                            "return optionTexts;",
                                                                            webElement);

                text = textObjects.Select(x => (string)x).ToList();
                break;
            }
            }
            return(text);
        }