public static bool SetText(this IWebElement element, string text) { try { string tagName = element.TagName.ToLower(); if (tagName == "input") { string type = element.GetAttribute("type").ToLower(); if (type == "text" || type == "password" || type == "numeric" || type == "number") { element.Clear(); element.SendKeys(text); return(true); } else if (type == "radio") { return(element.ClickSafe()); } else if (type == "checkbox") { if (text == "1" && !element.Selected) { return(element.ClickSafe()); } if (text == "0" && element.Selected) { return(element.ClickSafe()); } return(false); } else { //Handle other input types return(false); } } else if (tagName == "select") { SelectElement dropDown = new SelectElement(element); dropDown.SetOption(text); return(true); } else if (tagName == "textarea") { element.Clear(); element.SendKeys(text); return(true); } else { //Handle other html elements return(false); } } catch (UnhandledAlertException) { return(false); } }