Ejemplo n.º 1
0
        public static void FillOutTextBoxByName(IWebDriver webDriver, string textBoxName, string textToFillIn, int timeOutInSeconds = 180)
        {
            IWebElement element = WaitUtility.GetControl(webDriver, By.Name(textBoxName), timeOutInSeconds);

            if (element != null)
            {
                if (!element.Enabled)
                {
                    var js = (IJavaScriptExecutor)webDriver;
                    js.ExecuteScript("arguments[0].click();", element);
                    SleepHelper.Sleep(1000);
                }

                if (textToFillIn.Length > 100)
                {
                    string javaScript = String.Format("document.getElementsByName(\"{0}\")[0].value = \"{1}\";", textBoxName, textToFillIn);
                    ((IJavaScriptExecutor)webDriver).ExecuteScript(javaScript);
                }
                else
                {
                    element.Clear();
                    element.SendKeys(textToFillIn);
                }
            }
        }
Ejemplo n.º 2
0
 public static IWebElement GetElement(IWebDriver webDriver, By by, int timeOutInSeconds = 180)
 {
     return(WaitUtility.GetControl(webDriver, by, timeOutInSeconds));
 }
Ejemplo n.º 3
0
        public static string GetTextBy(IWebDriver webDriver, By by, int timeOutInSeconds = 180)
        {
            var item = WaitUtility.GetControl(webDriver, by, timeOutInSeconds);

            return(item.Text);
        }