Utility is being used to keep the actions waiting for a specified time or till the next required object/contorls avaiable
Inheritance: BaseClass
Example #1
0
        // TODO - Is this necessary?
        //public static FBLoginData GetBrowserBasedLoginCredentials(IWebDriver driver)
        //{
        //    var loginTestData = FBLoginData.GetLoginTestCases();
        //    string currentWebBrowserString = GetWebBrowser(driver);
        //    WebBrowsers currentWebBrowser;
        //    Enum.TryParse<WebBrowsers>(currentWebBrowserString, true, out currentWebBrowser);
        //    return loginTestData.FirstOrDefault(x => x.BrowserTypeEnum == (int)currentWebBrowser);
        //}

        /// <summary>
        /// Js the query date work around.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <param name="date">The date.</param>
        public static void JQueryDateWorkAround(IWebElement element, string date, int iter, IWebDriver driver = null, string XPath = null)
        {
            // workaround to get element by XPath in JS iteself
            var script             = string.Format("document.getElementById('{0}').value = ''", element.GetAttribute("id"));
            var javaScriptExecutor = (IJavaScriptExecutor)driver;
            var ele = (IWebElement)javaScriptExecutor.ExecuteScript(script);

            ThreadWait.StandardSleep(1);
            javaScriptExecutor.ExecuteScript(string.Format("document.getElementById('{0}').value = '{1}'", element.GetAttribute("id"), date));
        }
Example #2
0
        /// <summary>
        /// Clears the elements.
        /// </summary>
        /// <param name="elements">The elements.</param>
        public static void ClearElements(IWebElement[] elements)
        {
            if (elements != null)
            {
                foreach (var item in elements)
                {
                    item.Clear();
                }

                ThreadWait.StandardSleep(1);
            }
        }
Example #3
0
        public static bool VerifyLink(string link, IWebDriver driver, IWebElement element)
        {
            //Asumes the link is always a web page link. Not a link to a resource
            string currentWebBrowserString = GetWebBrowser(driver);
            var    downloadDir             = Configuration.DownloadsFolder;

            if (currentWebBrowserString == "Chrome")
            {
                element.Click();
                ThreadWait.StandardSleep(1);

                //new Actions(driver).SendKeys(driver.FindElement(By.TagName("html")), Keys.Control).SendKeys(driver.FindElement(By.TagName("html")), Keys.NumberPad2).Build().Perform();
                //Thread.Sleep(1);
                //new Actions(driver).SendKeys(driver.FindElement(By.TagName("html")), Keys.Control).SendKeys(driver.FindElement(By.TagName("html")), Keys.NumberPad1).Build().Perform();
                var popup = driver.WindowHandles[1]; // handler for the new tab
                if ((string.IsNullOrEmpty(popup)))
                {
                    return(false);
                }
                if (driver.SwitchTo().Window(popup).Url != link)
                {
                    return(false);
                }

                driver.SwitchTo().Window(driver.WindowHandles[1]).Close(); // close the tab
                driver.SwitchTo().Window(driver.WindowHandles[0]);         // get back to the main window
            }
            else if (currentWebBrowserString == "FireFox")
            {
            }
            else
            {
                throw new Exception();
            }
            return(true);
        }