Beispiel #1
0
        /// <summary>
        /// Waits for element.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <param name="waitCondition">The wait condition.</param>
        /// <param name="timeout">The timeout to wait before failing.</param>
        /// <returns><c>true</c> if the condition is met, <c>false</c> otherwise.</returns>
        public override bool WaitForElement(HtmlControl element, WaitConditions waitCondition, TimeSpan?timeout)
        {
            var milliseconds = (int)timeout.GetValueOrDefault(TimeSpan.FromSeconds(10)).TotalMilliseconds;

            switch (waitCondition)
            {
            case WaitConditions.Exists:
                return(element.WaitForControlExist(milliseconds));

            case WaitConditions.NotExists:
                return(element.WaitForControlNotExist(milliseconds));

            case WaitConditions.Enabled:
                return(element.WaitForControlCondition(e => e.Enabled, milliseconds));

            case WaitConditions.NotEnabled:
                return(element.WaitForControlCondition(e => !e.Enabled, milliseconds));

            case WaitConditions.NotMoving:
                element.WaitForControlExist(milliseconds);
                return(element.WaitForControlCondition(e => !this.Moving(e), milliseconds));
            }

            return(true);
        }
Beispiel #2
0
 public void AddCardsManually()
 {
     Driver.Wait.Until(
         WaitConditions.ElementIsDisplayed(Map.AddCardsManuallyLink))
     .Click();
     Driver.Wait.Until(WaitConditions.ElementDisplayed(Map.CopyDeckIcon));
 }
Beispiel #3
0
 public CopyDeckPage No()
 {
     Map.NoButton.Click();
     AcceptCookies();
     Driver.Wait.Until(WaitConditions.ElementDisplayed(Map.OtherStoresButton));
     return(this);
 }
Beispiel #4
0
 public void CuantoTePrestan(string ingresos, string plazo)
 {
     Map.IngresosMensuales.SendKeys(ingresos);
     new Select(Map.Plazo).SelectByText(plazo);
     Map.CalcularCredito.Click();
     Driver.Wait.Until(WaitConditions.ElementDisplayed(Map.Datos));
 }
Beispiel #5
0
 public WaitForWindowActionContext(IWindow window, string propertyName, WaitConditions waitCondition, TimeSpan?timeout)
     : base(propertyName)
 {
     this.Window        = window;
     this.WaitCondition = waitCondition;
     this.Timeout       = timeout;
 }
        public void LoginAsUser(string username)
        {
            try
            {
                var password = GetPasswordForUser(username);
                _userNameInput = Driver.FindElementWhenVisible(By.Id(_usernameInputId));
                _passwordInput = Driver.FindElementWhenVisible(By.Id(_passwordInputId));
                _loginBtn      = Driver.FindElementWhenVisible(By.Id(_loginBtnId));
                _userNameInput.Clear();
                _passwordInput.Clear();
                _userNameInput.SendKeys(username);
                _passwordInput.SendKeys(password);
                _loginBtn.Click();

                // Ordinarily would identify a state that implied that the home page load was complete
                // and wait for that state to exist i.e. the existance of an element that was late/last
                // to load or that a number of elements had been loaded.
                // In this instance will wait for element interested in to exist

                Driver.Wait.Until(WaitConditions
                                  .ElementIsDisplayedByLocator(By.CssSelector(HomePage.environmentalModuleCssLocator)));
            }
            catch (Exception e)
            {
                _logger.Error($"Unable to login as user {username}.");
                _logger.Error($"Error message {e.Message}.");
            }
        }
Beispiel #7
0
 public SavedRecordData CreateNewRecord(RecordData data)
 {
     OpenNewRecordPage();
     _recordPage.EnterRecord(data);
     _recordPage.SaveRecordAndClose();
     Driver.Wait.Until(WaitConditions.ElementIsDisplayedByLocator(By.CssSelector(_newRecordBtnCssSelector)));
     return(GetNewestRecord());
 }
Beispiel #8
0
        /// <summary>
        /// Calls the pipeline action.
        /// </summary>
        /// <param name="propertyName">Name of the property.</param>
        /// <param name="expectedCondition">The expected condition.</param>
        /// <param name="timeout">The timeout for waiting.</param>
        private void CallPipelineAction(string propertyName, WaitConditions expectedCondition, TimeSpan?timeout)
        {
            var page = this.GetPageFromContext();

            var context = new WaitForElementAction.WaitForElementContext(propertyName.ToLookupKey(), expectedCondition, timeout);

            this.actionPipelineService.PerformAction <WaitForElementAction>(page, context).CheckResult();
        }
Beispiel #9
0
 public void SelectDomicileCountryFromDropdown(string country)
 {
     //waiting for region dropdown to hide
     new WebDriverWait(driver, TimeSpan.FromSeconds(10))
     .Until(WaitConditions
            .ElementNotDisplayed(selectDomicileRegionDropdown.FindElement(By.XPath("//ul[contains(@class, 'domicileSelection__list--region')]"))));
     selectDomicileCountryDropdown.Click();
     selectDomicileCountryDropdown.FindElement(By.XPath("//li/a[contains(text(), '" + country + "')]")).Click();
 }
Beispiel #10
0
 public bool CheckNameMissingMessage(string message)
 {
     if (Driver.Wait.Until(WaitConditions.ElementDisplayed(_nameErrorMessage)))
     {
         return(_nameErrorMessage.Text.Equals(message) ? true : false);
     }
     else
     {
         return(false);
     }
 }
Beispiel #11
0
 public bool CheckDiscontinuedDateMissingMessage(string message)
 {
     if (Driver.Wait.Until(WaitConditions.ElementDisplayed(_inValidDate2ErrorMessage)))
     {
         return(_inValidDate2ErrorMessage.Text.Equals(message) ? true : false);
     }
     else
     {
         return(false);
     }
 }
Beispiel #12
0
 public void ClickCreate()
 {
     if (Driver.Wait.Until(WaitConditions.ElementDisplayed(_createButton)))
     {
         _createButton.Click();
     }
     else
     {
         throw new NoSuchElementException();
     }
 }
Beispiel #13
0
 public bool CheckRecordExists(string reference)
 {
     try
     {
         return(Driver.Wait.Until(WaitConditions.ElementDoesNotExist($"div.information a[title = '{reference}']")));
     }
     catch (Exception e)
     {
         _logger.Error($"Unable to validate existence of record with reference {reference}");
         _logger.Error($"Error message: {e.Message}");
         throw;
     }
 }
Beispiel #14
0
 private void OpenNewRecordPage()
 {
     try
     {
         _newRecordBtn = Driver.FindElementWhenVisible(By.CssSelector(_newRecordBtnCssSelector));
         _newRecordBtn.Click();
         Driver.Wait.Until(WaitConditions.ElementIsNotVisible(_spinnerId));
     }
     catch (Exception e)
     {
         _logger.Error($"Unable to open new Record page");
         _logger.Error($"Error message: {e.Message}");
         throw;
     }
 }
Beispiel #15
0
 public void DeleteRecord(int recordId)
 {
     try
     {
         ClickManageRecordBtn(recordId);
         var deleteRecordLink = Driver.FindElementWhenVisible(By.Id($"cogDelete{recordId}"));
         deleteRecordLink.Click();
         var confirmBtn = Driver.Wait.Until(WaitConditions.ElementIsDisplayedByLocator(By.XPath("//button[text()='Confirm']")));
         confirmBtn.Click();
     }
     catch (Exception e)
     {
         _logger.Error($"Unable to delete record with id {recordId}");
         _logger.Error($"Error message: {e.Message}");
         throw;
     }
 }
Beispiel #16
0
 public void OpenPageFromModule(string pageName, string moduleName)
 {
     try
     {
         _modulesMenuItem = Driver.FindElementWhenVisible(By.XPath(_modulesMenuItemXPathLocator));
         _modulesMenuItem.Click();
         var moduleMenuItem = Driver.FindElementWhenVisible(By.CssSelector($"li[data-areaname='{moduleName}']"));
         new Actions(Driver.Current).MoveToElement(moduleMenuItem).Build().Perform();
         var pageMenuItem = Driver.FindElementWhenVisible(By.CssSelector($"a[href*='{pageName.Replace(" ", "")}/Page']"));
         pageMenuItem.Click();
         Driver.Wait.Until(WaitConditions.ElementIsDisplayedByLocator(By.XPath($"//nav/strong[text()='{pageName}']")));
     }
     catch (Exception e)
     {
         _logger.Error($"Unable to open module {moduleName} and menu item {pageName}");
         _logger.Error($"Error message: {e.Message}");
         throw;
     }
 }
Beispiel #17
0
        private void WaitForWindow(string propertyName, WaitConditions waitCondition)
        {
            IApplication application   = this.GetApplicationFromContext();
            IWindow      currentWindow = this.GetWindowFromContext(true);

            IWindow parentWindow;

            switch (waitCondition)
            {
            case WaitConditions.Exists:
                // wait for a child window
                parentWindow = currentWindow;
                break;

            case WaitConditions.NotExists:
                // wait for the current window
                parentWindow = currentWindow.ParentWindow;
                break;

            default:
                throw new NotImplementedException($"Wait condition: {Enum.GetName(typeof(WaitConditions), waitCondition)}");
            }

            IWindow window = null;

            try
            {
                var context = new WaitForWindowAction.WaitForWindowActionContext(parentWindow ?? application, propertyName, waitCondition, null);
                window = this.actionPipelineService.PerformAction <WaitForWindowAction>(application, parentWindow ?? application, context)
                         .CheckResult <IWindow>();
            }
            finally
            {
                this.UpdateWindowContext(window ?? currentWindow.ParentWindow ?? application);
            }
        }
Beispiel #18
0
        /// <summary>
        /// Waits for the element to meet a certain condition.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <param name="waitCondition">The wait condition.</param>
        /// <param name="timeout">The timeout to wait before failing.</param>
        /// <returns><c>true</c> if the condition is met, <c>false</c> otherwise.</returns>
        public override bool WaitForElement(IWebElement element, WaitConditions waitCondition, TimeSpan?timeout)
        {
            var waiter = new DefaultWait <IWebElement>(element);

            waiter.Timeout = timeout.GetValueOrDefault(waiter.Timeout);

            waiter.IgnoreExceptionTypes(typeof(ElementNotVisibleException), typeof(NotFoundException));

            try
            {
                switch (waitCondition)
                {
                case WaitConditions.NotExists:
                    waiter.Until(e => !e.Displayed);
                    break;

                case WaitConditions.Enabled:
                    waiter.Until(e => e.Enabled);
                    break;

                case WaitConditions.NotEnabled:
                    waiter.Until(e => !e.Enabled);
                    break;

                case WaitConditions.Exists:
                    waiter.Until(e => e.Displayed);
                    break;
                }
            }
            catch (WebDriverTimeoutException)
            {
                return(false);
            }

            return(true);
        }
Beispiel #19
0
 /// <summary>
 /// Waits for element.
 /// </summary>
 /// <param name="element">The element.</param>
 /// <param name="waitCondition">The wait condition.</param>
 /// <param name="timeout">The timeout.</param>
 /// <returns><c>true</c> if the condition is met, <c>false</c> otherwise.</returns>
 public override bool WaitForElement(BaseElement element, WaitConditions waitCondition, TimeSpan?timeout)
 {
     return(false);
 }
Beispiel #20
0
 /// <summary>
 /// Waits for the element condition to be met.
 /// </summary>
 /// <param name="waitCondition">The wait condition.</param>
 /// <param name="timeout">The timeout to wait before failing.</param>
 /// <returns><c>true</c> if the condition is met, <c>false</c> otherwise.</returns>
 public override bool WaitForElementCondition(WaitConditions waitCondition, TimeSpan?timeout)
 {
     return(this.elementAction(this.ElementHandler, o => this.ElementHandler.WaitForElement(o, waitCondition, timeout)));
 }
Beispiel #21
0
 public bool isPageLoaded()
 {
     return(Driver.Wait.Until(WaitConditions.ElementDisplayed(_pageHeading)));
 }
Beispiel #22
0
 /// <summary>
 /// Waits for control condition to be met.
 /// </summary>
 /// <param name="control">The control.</param>
 /// <param name="waitCondition">The wait condition.</param>
 /// <param name="timeout">The time to wait before failing.</param>
 /// <returns><c>true</c> if the condition is met, <c>false</c> otherwise.</returns>
 public abstract bool WaitForControl(TControl control, WaitConditions waitCondition, TimeSpan?timeout);
Beispiel #23
0
 /// <summary>
 /// Waits for the control condition to be met.
 /// </summary>
 /// <param name="waitCondition">The wait condition.</param>
 /// <param name="timeout">The timeout to wait before failing.</param>
 /// <returns><c>true</c> if the condition is met, <c>false</c> otherwise.</returns>
 public override bool WaitForControlCondition(WaitConditions waitCondition, TimeSpan?timeout)
 {
     return(this.controlAction(this.ControlHandler, o => this.ControlHandler.WaitForControl(o, waitCondition, timeout)));
 }
Beispiel #24
0
 public void AcceptCookies()
 {
     Map.AcceptCookiesButton.Click();
     Driver.wait.Until(WaitConditions.ElementNotDisplayed(Map.AcceptCookiesButton));
 }
 public CopyDeckPage Yes()
 {
     Map.YesButton.Click();
     Driver.Wait.Until(WaitConditions.ElementDisplayed(Map.CopiedMessage));
     return(this);
 }
Beispiel #26
0
        /// <summary>
        /// Calls the pipeline action.
        /// </summary>
        /// <param name="propertyName">Name of the property.</param>
        /// <param name="expectedCondition">The expected condition.</param>
        /// <param name="timeout">The timeout for waiting.</param>
        private void CallPipelineAction(string propertyName, WaitConditions expectedCondition, TimeSpan? timeout)
        {
            var page = this.GetPageFromContext();

            var context = new WaitForElementAction.WaitForElementContext(propertyName.ToLookupKey(), expectedCondition, timeout);
            this.actionPipelineService.PerformAction<WaitForElementAction>(page, context).CheckResult();
        }
Beispiel #27
0
        /// <summary>
        /// Waits for the element to meet a certain condition.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <param name="waitCondition">The wait condition.</param>
        /// <param name="timeout">The timeout to wait before failing.</param>
        /// <returns><c>true</c> if the condition is met, <c>false</c> otherwise.</returns>
        public override bool WaitForElement(IWebElement element, WaitConditions waitCondition, TimeSpan?timeout)
        {
            var waiter = new DefaultWait <IWebElement>(element);

            waiter.Timeout = timeout.GetValueOrDefault(waiter.Timeout);

            try
            {
                switch (waitCondition)
                {
                case WaitConditions.BecomesNonExistent:     // AKA NotExists
                    this.ExecuteWithElementLocateTimeout(
                        new TimeSpan(),
                        () =>
                    {
                        try
                        {
                            waiter.Until(e => !e.Displayed);
                        }
                        catch (NoSuchElementException)
                        {
                        }
                        catch (NotFoundException)
                        {
                        }
                        catch (ElementNotVisibleException)
                        {
                        }
                        catch (StaleElementReferenceException)
                        {
                        }
                    });
                    break;

                case WaitConditions.RemainsNonExistent:
                    return(this.EvaluateWithElementLocateTimeout(
                               waiter.Timeout,
                               () =>
                    {
                        try
                        {
                            return this.DoesFullTimeoutElapse(waiter, e => e.Displayed);
                        }
                        catch (NoSuchElementException)
                        {
                            return true;
                        }
                        catch (NotFoundException)
                        {
                            return true;
                        }
                        catch (ElementNotVisibleException)
                        {
                            return true;
                        }
                        catch (StaleElementReferenceException)
                        {
                            return true;
                        }
                    }));

                case WaitConditions.BecomesEnabled:     // AKA Enabled
                    waiter.IgnoreExceptionTypes(typeof(ElementNotVisibleException), typeof(NotFoundException));
                    waiter.Until(e => e.Enabled);
                    break;

                case WaitConditions.BecomesDisabled:     // AKA NotEnabled
                    waiter.IgnoreExceptionTypes(typeof(ElementNotVisibleException), typeof(NotFoundException));
                    waiter.Until(e => !e.Enabled);
                    break;

                case WaitConditions.BecomesExistent:     // AKA Exists
                    waiter.IgnoreExceptionTypes(typeof(ElementNotVisibleException), typeof(NotFoundException));
                    waiter.Until(e => e.Displayed);
                    break;

                case WaitConditions.NotMoving:
                    waiter.IgnoreExceptionTypes(typeof(ElementNotVisibleException), typeof(NotFoundException));
                    waiter.Until(e => e.Displayed);
                    waiter.Until(e => !this.Moving(e));
                    break;

                case WaitConditions.RemainsEnabled:
                    return(this.DoesFullTimeoutElapse(waiter, e => !e.Enabled));

                case WaitConditions.RemainsDisabled:
                    return(this.DoesFullTimeoutElapse(waiter, e => e.Enabled));

                case WaitConditions.RemainsExistent:
                    return(this.DoesFullTimeoutElapse(waiter, e => !e.Displayed));
                }
            }
            catch (WebDriverTimeoutException)
            {
                return(false);
            }

            return(true);
        }
Beispiel #28
0
 /// <summary>
 /// Waits for the element condition to be met.
 /// </summary>
 /// <param name="waitCondition">The wait condition.</param>
 /// <param name="timeout">The timeout to wait before failing.</param>
 /// <returns><c>true</c> if the condition is met, <c>false</c> otherwise.</returns>
 public virtual bool WaitForElementCondition(WaitConditions waitCondition, TimeSpan?timeout)
 {
     throw this.CreateNotSupportedException("Waiting for an element");
 }
Beispiel #29
0
 /// <summary>
 /// Waits for element condition to be met.
 /// </summary>
 /// <param name="element">The element.</param>
 /// <param name="waitCondition">The wait condition.</param>
 /// <param name="timeout">The time to wait before failing.</param>
 /// <returns><c>true</c> if the condition is met, <c>false</c> otherwise.</returns>
 public abstract bool WaitForElement(TElement element, WaitConditions waitCondition, TimeSpan?timeout);
 /// <summary>
 /// Initializes a new instance of the <see cref="WaitForElementContext" /> class.
 /// </summary>
 /// <param name="propertyName">Name of the property.</param>
 /// <param name="condition">The condition.</param>
 /// <param name="timeout">The timeout for waiting.</param>
 public WaitForElementContext(string propertyName, WaitConditions condition, TimeSpan?timeout)
     : base(propertyName)
 {
     this.Condition = condition;
     this.Timeout   = timeout;
 }
Beispiel #31
0
 public bool IsSuccessMessagePresent()
 {
     return(Driver.Wait.Until(WaitConditions.ElementDisplayed(_seccussMessage)));
 }