/// <summary> /// Method to enter text to Desired editbox /// </summary> /// Authour: Vamsi krishna Boyapati /// Date:25th-March-2013 /// <param name="objMySelenium">Selenium RC instance</param> /// <param name="strLocator">Locator of the Control/Element(Xpath)</param> /// <param name="strText"> string text</param> /// <returns>Boolean value(True/False)</returns> public bool EnterTextToEditBox(ISelenium objMySelenium, string strLocator, string strText) { bool bStatus = true; IWebDriver objMyWebDriver = ((WebDriverBackedSelenium)objMySelenium).UnderlyingWebDriver; TimeSpan ts = new TimeSpan(0, 0, 60); objMyWebDriver.Manage().Timeouts().ImplicitlyWait(ts); try { if (objMyWebDriver.FindElement(By.XPath(strLocator)).Displayed) { if (objMySelenium.IsEditable(strLocator)) { objMyWebDriver.FindElement(By.XPath(strLocator)).Click(); Thread.Sleep(2000); objMyWebDriver.FindElement(By.XPath(strLocator)).SendKeys(strText); } else { bStatus = false; } } else { bStatus = false; } } catch (AutomationException EX) { Console.WriteLine(EX.Message); } return(bStatus); }
public bool WaitUntilElementEditable(ISelenium myBrowser, string locator, string timeout) { DateTime endTime = DateTime.Now.AddMilliseconds(Convert.ToDouble(timeout, CultureInfo.CurrentCulture)); while (endTime > DateTime.Now) { if (myBrowser.IsEditable(locator)) { return(true); } else { Thread.Sleep(Convert.ToInt32(Convert.ToDouble(timeout, CultureInfo.CurrentCulture) / 10.0, CultureInfo.CurrentCulture)); } } throw new AutomationException("Element with search critera '" + locator + "' is not editable."); }