Ejemplo n.º 1
0
        /// <summary>
        /// Wait for the Element to exists before assignment.
        /// </summary>
        /// <param name="byObj">Locator Identification</param>
        private bool WaitAndGetElement(By bBy)
        {
            bool result         = true;
            var  elementInfocus = DriverWait(uint.Parse(FrameGlobals.strImplicitWait)).Until(d =>
            {
                try
                {
                    _iWebElement = _iDriver.FindElement(bBy);

                    if (!_iWebElement.Displayed)
                    {
                        result = false;
                    }
                }
                catch (ElementNotVisibleException)
                {
                    _iWebElement = DriverWait().Until(driver => driver.FindElement(bBy));
                    if (!_iWebElement.Displayed)
                    {
                        Hooks.CaptureScreenshot(_iDriver);
                        this._scenarioContext.Add("Exception", "Element is not visisble. Please check element location and try run test again.");
                    }
                }
                catch (Exception ex)
                {
                    Hooks.CaptureScreenshot(_iDriver);
                    this._scenarioContext.Add("Exception", ex.Message);
                }
                return(_iWebElement);
            });

            return(result);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Method used to click on WebElement
 /// </summary>
 /// <param name="byObj">By object</param>
 public void Click(By bBy)
 {
     WaitAndGetElement(bBy);
     try
     {
         _iWebElement.Click();
     }catch (StaleElementReferenceException)
     {
         _iDriver.FindElement(bBy).Click();
     }catch (Exception ex)
     {
         Hooks.CaptureScreenshot(_iDriver);
         this._scenarioContext.Add("Exception", ex.Message);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Wait for multiple elements and returns true If all elements are found otherwise false
        /// </summary>
        /// <param name="byObj">Element locator</param>
        /// <returns>Returns true If all elements are found otherwise false</returns>
        protected bool WaitAndGetElements(By bBy)
        {
            bool bGetElement = false;

            try
            {
                _iWebElementList = _iDriver.FindElements(bBy);
                foreach (var element in _iWebElementList)
                {
                    if (!(DriverWait(uint.Parse(FrameGlobals.strImplicitWait)).Until(d => element).Enabled))
                    {
                        Hooks.CaptureScreenshot(_iDriver);
                        this._scenarioContext.Add("Exception", "Time out exception. Please try run test case again.");
                    }
                }
                bGetElement = true;
            }catch (Exception ex)
            {
                Hooks.CaptureScreenshot(_iDriver);
                this._scenarioContext.Add("Exception", ex.Message);
            }
            return(bGetElement);
        }