示例#1
0
        /// <summary>
        /// Click on a web element and wait for page load
        /// </summary>
        /// <param name="pElement">The Web Element is used</param>
        public static void Click(By pBy)
        {
            IWebElement pElement = F_General.CaptureInterface(pBy);

            ((IJavaScriptExecutor)ConstantsLib.Driver).ExecuteScript("arguments[0].scrollIntoView(true);" + "window.scrollBy(0,-100);", pElement);
            pElement.Click();
        }
示例#2
0
        /// <summary>
        /// Wait until an element is not visible
        /// </summary>
        /// <param name="pBy">Provides a mechanism by which to find elements within a document</param>
        /// <param name="pTimeout">The maximum time to wait</param>
        public static void WaitForElementNotVisible(By pBy, int pTimeout = 0)
        {
            if (pTimeout == 0)
            {
                pTimeout = ConstantsLib.TimeOut;
            }

            DateTime first  = DateTime.Now;
            DateTime second = DateTime.Now;

            ConstantsLib.Driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(Convert.ToDouble(5)));
            while ((second - first).Seconds <= pTimeout)
            {
                IWebElement mEle = F_General.CaptureInterface(pBy);
                if (mEle != null && mEle.Displayed)
                {
                    Thread.Sleep(1000);
                    second = DateTime.Now;
                }
                else
                {
                    break;
                }
            }
        }
示例#3
0
        /// <summary>
        /// Wait for element attribute changed to expected value
        /// </summary>
        /// <param name="pBy">Provides a mechanism by which to find elements within a document/param>
        /// <param name="pAttribute">The attribute name</param>
        /// <param name="pExpectedValue">Value need to wait to be changed</param>
        /// <param name="pTimeout">Maximum time to wait (seconds)</param>
        public static void WaitForElementAttributeChangedToExpectedValue(By pBy, string pAttribute, string pExpectedValue, int pTimeout = 0)
        {
            if (pTimeout == 0)
            {
                pTimeout = ConstantsLib.TimeOut;
            }

            DateTime    mFrom = DateTime.Now;
            IWebElement mEle  = F_General.CaptureInterface(pBy);
            DateTime    mTo   = DateTime.Now;

            while ((mTo - mFrom).Seconds < pTimeout)
            {
                if (!mEle.GetAttribute(pAttribute).Contains(pExpectedValue))
                {
                    Thread.Sleep(2000);
                }
                else
                {
                    break;
                }
            }
        }
示例#4
0
        /// <summary>
        /// Wait for element attribute changed to another value
        /// </summary>
        /// <param name="pBy">Provides a mechanism by which to find elements within a document/param>
        /// <param name="pAttribute">The attribute name</param>
        /// <param name="pDefaultValue">Value need to wait to be changed</param>
        /// <param name="pTimeout">Maximum time to wait (seconds)</param>
        public static void WaitForElementAttributeChanged(By pBy, string pAttribute, string pDefaultValue, bool pIsExact = false, int pTimeout = 0)
        {
            if (pTimeout == 0)
            {
                pTimeout = ConstantsLib.TimeOut;
            }

            DateTime mFrom = DateTime.Now;
            DateTime mTo   = DateTime.Now;

            while ((mTo - mFrom).Seconds < pTimeout)
            {
                IWebElement mEle = F_General.CaptureInterface(pBy);
                if (pIsExact == false)
                {
                    if (mEle.GetAttribute(pAttribute).Contains(pDefaultValue))
                    {
                        Thread.Sleep(2000);
                        mTo = DateTime.Now;
                    }
                    else
                    {
                        break;
                    }
                }
                else if (mEle.GetAttribute(pAttribute) == pDefaultValue)
                {
                    Thread.Sleep(2000);
                    mTo = DateTime.Now;
                }
                else
                {
                    break;
                }
            }
        }
示例#5
0
        /// <summary>
        /// Wait until an element is visible
        /// </summary>
        /// <param name="pBy">Provides a mechanism by which to find elements within a document</param>
        /// <param name="pTimeout">The maximum time to wait</param>
        public static void WaitForElementVisible(By pBy, int pTimeout = 0)
        {
            if (pTimeout == 0)
            {
                pTimeout = ConstantsLib.TimeOut;
            }

            DateTime first  = DateTime.Now;
            DateTime second = DateTime.Now;

            while ((second - first).Seconds <= pTimeout)
            {
                IWebElement mEle = F_General.CaptureInterface(pBy);
                if (mEle == null || mEle.Displayed == false)
                {
                    Thread.Sleep(1000);
                    second = DateTime.Now;
                }
                else
                {
                    break;
                }
            }
        }
示例#6
0
 /// <summary>
 /// Unselect checkbox if it is checked
 /// </summary>
 /// <param name="pBy">Provides a mechanism by which to find elements within a document</param>
 public static void UnselectCheckbox(By pBy)
 {
     UnselectCheckbox(F_General.CaptureInterface(pBy));
 }
示例#7
0
 /// <summary>
 /// Select a value in a third party dropdown list
 /// </summary>
 /// <param name="pBy">Provides a mechanism by which to find elements within a document</param>
 /// <param name="pValue">The selected value</param>
 public static void SelectTelerikDropdown(By pBy, string pValue)
 {
     SelectTelerikDropdown(F_General.CaptureInterface(pBy), pValue);
 }
示例#8
0
 /// <summary>
 /// Capture the UI control and click on it
 /// </summary>
 /// <param name="pBy"></param>
 public static void Click(By pBy)
 {
     Click(F_General.CaptureInterface(pBy));
 }
示例#9
0
 /// <summary>
 /// Click on a web element
 /// </summary>
 /// <param name="pBy">Provides a mechanism by which to find elements within a document</param>
 public static void TelerikClick(By pBy)
 {
     TelerikClick(F_General.CaptureInterface(pBy));
 }
示例#10
0
 /// <summary>
 /// Telerik Send Key
 /// </summary>
 /// <param name="pBy">Provides a mechanism by which to find elements within a document</param>
 /// <param name="pValue">The string to type to the element</param>
 public static void TelerikSendKey(By pBy, string pValue)
 {
     TelerikSendKey(F_General.CaptureInterface(pBy), pValue);
 }