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
        /// <summary>
        /// Automates the sign up process for a user
        /// </summary>
        public bool SignUp()
        {
            PageDriverHelper.GoToUrl(_webDriver, _pageElements["ApplicationURL"]));

            WaitUtility.WaitForPageLoadComplete(_webDriver, 180);
            WaitUtility.WaitForLoadingPageToComplete(_webDriver, 180);
            ScreenshotHelper.TaskScreenShotAndUpload(_webDriver, Directory.GetCurrentDirectory();
	    return true;
        }
Ejemplo n.º 3
0
        public static void ClickAlert(IWebDriver webDriver)
        {
            IAlert alert = WaitUtility.WaitAlertToBePresent(webDriver);

            if (alert != null)
            {
                alert.Accept();
            }
        }
Ejemplo n.º 4
0
        public static void SelectItem(IWebDriver webDriver, By by, string textToSelect, int timeOutInSeconds = 180)
        {
            var item = WaitUtility.WaitToDisplay(webDriver, by, timeOutInSeconds);

            if (item != null)
            {
                var selectItem = new SelectElement(item);
                selectItem.SelectByText(textToSelect);
            }
        }
Ejemplo n.º 5
0
        public static IWebElement FillOutTextBoxById(IWebDriver webDriver, string textBoxId, string textToFillIn, int timeOutInSeconds = 180)
        {
            var textBox = WaitUtility.WaitToDisplayByControlId(webDriver, textBoxId, timeOutInSeconds);

            if (textBox != null)
            {
                if (textToFillIn.Length > 100)
                {
                    string javaScript = String.Format("document.getElementById(\"{0}\").value = \"{1}\";", textBoxId, textToFillIn);
                    ((IJavaScriptExecutor)webDriver).ExecuteScript(javaScript);
                }
                else
                {
                    textBox.Clear();
                    textBox.SendKeys(textToFillIn);
                }
            }

            return(textBox);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Wait for the given element to appear AND have a text which is not an empty string, then return its text value.
        /// If unable to achieve this within the allotted time, an exception will be thrown.
        /// </summary>
        /// <param name="webDriver"></param>
        /// <param name="by"></param>
        /// <param name="timeoutInSeconds"></param>
        /// <returns>The element's text/value.</returns>
        public static string WaitForNonEmptyValueThenGetValue(IWebDriver webDriver, By by, int timeoutInSeconds)
        {
            var element = WaitUtility.WaitForNonEmptyText(webDriver, by, timeoutInSeconds);

            return(element.GetAttribute("value"));
        }
Ejemplo n.º 7
0
 public static IWebElement GetElement(IWebDriver webDriver, By by, int timeOutInSeconds = 180)
 {
     return(WaitUtility.GetControl(webDriver, by, timeOutInSeconds));
 }
Ejemplo n.º 8
0
        public static string GetTextBy(IWebDriver webDriver, By by, int timeOutInSeconds = 180)
        {
            var item = WaitUtility.GetControl(webDriver, by, timeOutInSeconds);

            return(item.Text);
        }