/// <summary> /// Clicks and handles alert by accepting it, dismissing it or just waits for it and doesn't treat it automatically. /// </summary> /// <param name="alertResolveStatus">Accepts, dissmisses or doesn't treats the alert.</param> /// <param name="timeToWaitForAlert">Represents the time allocated for detecting the alert popup. Applies only to Accept and Dismiss alert resolve statuses. Value is in milliseconds.</param> /// <param name="skipPageCreation"></param> /// <param name="waitForPageToLoadAfterAlert"></param> /// <returns></returns> public virtual object ClickAndTreatAlert(AlertResolveType alertResolveStatus = AlertResolveType.Accept, int timeToWaitForAlert = 60000, bool skipPageCreation = false, bool waitForPageToLoadAfterAlert = true) { if (alertResolveStatus == AlertResolveType.TreatAfter) { return(Click(true, false, alertResolveStatus, timeToWaitForAlert, false, false)); } return(Click(true, true, alertResolveStatus, timeToWaitForAlert, skipPageCreation, waitForPageToLoadAfterAlert)); }
public T ClickAndTreatAlertAndOpenPage(AlertResolveType alertResolveStatus = AlertResolveType.Accept, int timeToWaitForAlert = 60000) { ParentPage.LastKnownWindowHandle = ParentPage.Driver.CurrentWindowHandle; ParentPage.WindowHandlesSnapshot = ParentPage.Driver.WindowHandles; ClickAndTreatAlert(alertResolveStatus, timeToWaitForAlert, true, false); var page = GetPageInstance(null) as T; return(page); }
public T ClickAndTreatAlertAndOpenPopup(ContainerWebElement popupContainer, AlertResolveType alertResolveStatus = AlertResolveType.Accept, int timeToWaitForAlert = 60000) { ParentPage.LastKnownWindowHandle = ParentPage.Driver.CurrentWindowHandle; ParentPage.WindowHandlesSnapshot = ParentPage.Driver.WindowHandles; ClickAndTreatAlert(alertResolveStatus, timeToWaitForAlert, true); var page = GetPageInstance(popupContainer) as T; return(page); }
/// <summary> /// Clicks and waits for the page to fully load: _title to change (if navigating to new page), updater overlay to dissapear, pending ajax calls to finish. /// VERY IMPORTANT: In case alerts appear use ClickAndTreatAlert() as it detects alerts /// </summary> /// <param name="waitForItself"></param> /// <param name="waitForPageToLoad"></param> /// <param name="alertResolveStatus">The way the popup/alert is treated. True = accept alert, False = cancel alert, DontResolve = leave alert</param> /// <param name="timeToWaitForAlert">Represents the time allocated for detecting the alert popup. Applies only to Accept and Dismiss alert resolve statuses. Value is in milliseconds</param> /// <param name="skipPageCreation"></param> /// <param name="waitForPageToLoadAfterAlert"></param> /// <returns></returns> public virtual object Click(bool waitForItself = true, bool waitForPageToLoad = true, AlertResolveType alertResolveStatus = AlertResolveType.TreatAfter, int timeToWaitForAlert = 500, bool skipPageCreation = false, bool waitForPageToLoadAfterAlert = true) { ParentPage.WaitForDynamicContentToLoad(); var result = ClickNoWait(waitForItself, skipPageCreation); var newPage = (result != null); bool pageAlert; if (newPage) { ((BasePage)result).WaitForAlert(timeToWaitForAlert); //check for alert popups as default, but for treating them use ClickAndTreatAlert() _log.Info(String.Format("Click(): Page alert popup status = {0}.", ((BasePage)result).IsAlertPresent)); pageAlert = ((BasePage)result).IsAlertPresent; } else { ParentPage.WaitForAlert(timeToWaitForAlert); _log.Info(String.Format("Click(): Page alert popup status = {0}", ParentPage.IsAlertPresent)); pageAlert = ParentPage.IsAlertPresent; } if (pageAlert) { _log.Info(String.Format("Alert Message: {0}", ParentPage.Alert.Text)); switch (alertResolveStatus) { case AlertResolveType.Accept: if (newPage) { ((BasePage)result).AcceptAlert(waitForPageToLoadAfterAlert); } else { ParentPage.AcceptAlert(waitForPageToLoadAfterAlert); } break; case AlertResolveType.Dismiss: if (newPage) { ((BasePage)result).DismissAlert(waitForPageToLoadAfterAlert); } else { ParentPage.DismissAlert(waitForPageToLoadAfterAlert); } break; case AlertResolveType.TreatAfter: break; } } if (waitForPageToLoad && !pageAlert) { if (!newPage) { ParentPage.WaitForDynamicContentToLoad(); } } return(result); }
/// <summary> /// Clicks and handles alert by accepting it, dismissing it or just waits for it and doesn't treat it automatically. /// </summary> /// <param name="alertResolveStatus">Accepts, dissmisses or doesn't treats the alert.</param> /// <param name="timeToWaitForAlert">Represents the time allocated for detecting the alert popup. Applies only to Accept and Dismiss alert resolve statuses. Value is in milliseconds.</param> /// <param name="skipPageCreation"></param> /// <param name="waitForPageToLoadAfterAlert"></param> /// <returns></returns> public virtual object ClickAndTreatAlert(AlertResolveType alertResolveStatus = AlertResolveType.Accept, int timeToWaitForAlert = 60000, bool skipPageCreation = false, bool waitForPageToLoadAfterAlert = true) { if (alertResolveStatus == AlertResolveType.TreatAfter) return Click(true, false, alertResolveStatus, timeToWaitForAlert, false, false); return Click(true, true, alertResolveStatus, timeToWaitForAlert, skipPageCreation, waitForPageToLoadAfterAlert); }
/// <summary> /// Clicks and waits for the page to fully load: _title to change (if navigating to new page), updater overlay to dissapear, pending ajax calls to finish. /// VERY IMPORTANT: In case alerts appear use ClickAndTreatAlert() as it detects alerts /// </summary> /// <param name="waitForItself"></param> /// <param name="waitForPageToLoad"></param> /// <param name="alertResolveStatus">The way the popup/alert is treated. True = accept alert, False = cancel alert, DontResolve = leave alert</param> /// <param name="timeToWaitForAlert">Represents the time allocated for detecting the alert popup. Applies only to Accept and Dismiss alert resolve statuses. Value is in milliseconds</param> /// <param name="skipPageCreation"></param> /// <param name="waitForPageToLoadAfterAlert"></param> /// <returns></returns> public virtual object Click(bool waitForItself = true, bool waitForPageToLoad = true, AlertResolveType alertResolveStatus = AlertResolveType.TreatAfter, int timeToWaitForAlert = 500, bool skipPageCreation = false, bool waitForPageToLoadAfterAlert = true) { ParentPage.WaitForDynamicContentToLoad(); var result = ClickNoWait(waitForItself, skipPageCreation); var newPage = (result != null); bool pageAlert; if (newPage) { ((BasePage)result).WaitForAlert(timeToWaitForAlert); //check for alert popups as default, but for treating them use ClickAndTreatAlert() _log.Info(String.Format("Click(): Page alert popup status = {0}.", ((BasePage)result).IsAlertPresent)); pageAlert = ((BasePage)result).IsAlertPresent; } else { ParentPage.WaitForAlert(timeToWaitForAlert); _log.Info(String.Format("Click(): Page alert popup status = {0}", ParentPage.IsAlertPresent)); pageAlert = ParentPage.IsAlertPresent; } if (pageAlert) { _log.Info(String.Format("Alert Message: {0}", ParentPage.Alert.Text)); switch (alertResolveStatus) { case AlertResolveType.Accept: if (newPage) ((BasePage)result).AcceptAlert(waitForPageToLoadAfterAlert); else ParentPage.AcceptAlert(waitForPageToLoadAfterAlert); break; case AlertResolveType.Dismiss: if (newPage) ((BasePage)result).DismissAlert(waitForPageToLoadAfterAlert); else ParentPage.DismissAlert(waitForPageToLoadAfterAlert); break; case AlertResolveType.TreatAfter: break; } } if (waitForPageToLoad && !pageAlert) { if (!newPage) { ParentPage.WaitForDynamicContentToLoad(); } } return result; }