public virtual void Dispose() { if (!MessageModalProxyExtensions.IsMessageModalPresent(this.Selenium)) { if (!AvoidClose) { try { if (this.Element.IsStale()) { return; } var button = this.CloseButton.TryFind(); if (button != null && button.Displayed) { button.Click(); } } catch (ElementNotVisibleException) { } catch (StaleElementReferenceException) { } this.WaitNotVisible(); } } Disposing?.Invoke(OkPressed); }
//public void CloseDiscardChanges() not in use //{ // this.CloseButton.Find().Click(); // Selenium.ConsumeAlert(); // this.WaitNotVisible(); //} public override void Dispose() { if (!AvoidClose) { string?confirmationMessage = null; Selenium.Wait(() => { if (this.Element.IsStale()) { return(true); } if (TryToClose()) { return(true); } if (MessageModalProxyExtensions.IsMessageModalPresent(this.Selenium)) { var alert = MessageModalProxyExtensions.GetMessageModal(this.Selenium) !; alert.Click(MessageModalButton.Yes); } return(false); }, () => "popup {0} to disapear with or without confirmation".FormatWith()); if (confirmationMessage != null) { throw new InvalidOperationException(confirmationMessage); } } Disposing?.Invoke(this.OkPressed); }
//[DebuggerStepThrough] //public static bool IsAlertPresent(this RemoteWebDriver selenium) //{ // try // { // selenium.SwitchTo().Alert(); // return true; // } // catch (NoAlertPresentException) // { // return false; // } //} public static void ConsumeAlert(this RemoteWebDriver selenium) { var alertPresent = selenium.Wait(() => MessageModalProxyExtensions.IsMessageModalPresent(selenium)); var alert = selenium.Wait(() => selenium.SwitchTo().Alert()); alert.Accept(); }
public void OkWaitClosed(bool consumeAlert = false) { this.OkButton.Find().Click(); if (consumeAlert) { MessageModalProxyExtensions.CloseMessageModal(this.Selenium, MessageModalButton.Ok); } this.WaitNotVisible(); this.OkPressed = true; }