//public void ClickDeleteLink() //{ // Delete_Link.Click(); //} /// <summary> /// delete the Passage /// </summary> public void ClickDeleteLink(bool isItemLinked) { this.Parent.CurrentWindowHandle = Driver.CurrentWindowHandle; Report.Write("The current window is: '" + this.Parent.CurrentWindowHandle + "'."); Delete_Link.Wait(2).Click(); IAlert alert = Driver.SwitchTo().Alert(); string expected1 = "Are you sure you wish to delete this passage?"; string expected2 = "Warning: All 1 Items linked to passage will be deleted."; string actual = alert.Text; Report.Write("The alert text: '" + actual + "'."); if (isItemLinked) { Assert.IsTrue(actual.Contains(expected2), "The delete confirmation pop-up does not contain the expected text: '" + expected1 + "'; actual text: '" + actual + "'."); } else { Assert.IsTrue(actual.Contains(expected1), "The delete confirmation pop-up does not contain the expected text: '" + expected1 + "'; actual text: '" + actual + "'."); } alert.Accept(); //switch to window DriverCommands.WaitToSwitchWindow(this.Parent.CurrentWindowHandle, 5); //wait for page to load after delete DriverCommands.WaitAndMeasurePageLoadTime(); }
/// <summary> /// Delete the item and Accept the Alert. /// </summary> public void DeleteItem() { this.Parent.CurrentWindowHandle = Driver.CurrentWindowHandle; Report.Write("The current window is: '" + this.Parent.CurrentWindowHandle + "'."); Utilities.FocusOnMainContentArea(); //stop hover over menu Delete_Link.Wait(3).Click(); AlertHandler alert = new AlertHandler(); alert.VerifyText("Are you sure you wish to delete this item?"); alert.Accept(); //switch to window DriverCommands.WaitToSwitchWindow(this.Parent.CurrentWindowHandle, 5); }