/// <summary> /// Clicks the user-specified element and then waits for a window to close or open, or a page to load, /// depending on the element that was clicked /// </summary> /// <param name="buttonOrLinkElem">The button element</param> public dynamic ClickAndWait(IWebElement buttonOrLinkElem) { if (Browser.Exists(Bys.MyCPDActivitiesListPage.EnterACPDActivityBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == EnterACPDActivityBtn.GetAttribute("outerHTML")) { EnterACPDActivityBtn.Click(); Browser.WaitForElement(Bys.EnterCPDActivityPage.EnterACPDFrame, ElementCriteria.IsVisible); EnterCPDActivityPage EAP = new EnterCPDActivityPage(Browser); EAP.WaitForInitialize(); Browser.SwitchTo().Frame(EAP.EnterACPDFrame); return(EAP); } } if (Browser.Exists(Bys.MyCPDActivitiesListPage.DeleteActivityFormOkBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == DeleteActivityFormOkBtn.GetAttribute("outerHTML")) { DeleteActivityFormOkBtn.Click(); // Mike J 12/21/2017: I tried everything to implement a dynamic wait here, but couldnt find a way to do it. I tried to wait until // various different loading elements disappear, but none of them worked. I even element inspected the exact circle load icon that // I visually see when we click the delete button, but that didnt work, as its not within the body of the HTML. We might have to use // a static wait here. Dont waste time trying to implement a dynamic wait later on, as I dont think its possible, or if it is, it // is very hidden Thread.Sleep(10000); return(null); } } else { throw new Exception("No button or link was found with your passed parameter. You either need to add this button to a new If statement, " + "or if the button is already added, then the page you were on did not contain the button."); } return(null); }
/// <summary> /// Clicks the user-specified element and then waits for a window to close or open, or a page to load, /// depending on the element that was clicked /// </summary> /// <param name="buttonOrLinkElem">The button element</param> public dynamic ClickAndWait(IWebElement buttonOrLinkElem) { // Error handler to make sure that the button that the tester passed in the parameter is actually on the page if (Browser.Exists(Bys.MyDashboardPage.EnterACPDActivityBtn)) { // This is a workaround to be able to use an IF statement on an IWebElement type. if (buttonOrLinkElem.GetAttribute("outerHTML") == EnterACPDActivityBtn.GetAttribute("outerHTML")) { buttonOrLinkElem.Click(); Browser.WaitForElement(Bys.EnterCPDActivityPage.EnterACPDFrame, ElementCriteria.IsVisible); EnterCPDActivityPage EAP = new EnterCPDActivityPage(Browser); EAP.WaitForInitialize(); Browser.SwitchTo().Frame(EAP.EnterACPDFrame); return(EAP); } } if (Browser.Exists(Bys.MyDashboardPage.AddAGoalBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == AddAGoalBtn.GetAttribute("outerHTML")) { buttonOrLinkElem.Click(); SwitchToFrame(Bys.MyDashboardPage.CreateAGoalFrame, CreateAGoalFrame, Bys.MyDashboardPage.CreateAGoalFormNextBtnTxt); return(null); } } if (Browser.Exists(Bys.MyDashboardPage.CreateAGoalFormNextBtnTxt)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == CreateAGoalFormNextBtnTxt.GetAttribute("outerHTML")) { buttonOrLinkElem.Click(); this.WaitUntil(Criteria.MyDashboardPage.CreateAGoalFormCloseBtnVisible); return(null); } } if (Browser.Exists(Bys.MyDashboardPage.CreateAGoalFormCloseBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == CreateAGoalFormCloseBtn.GetAttribute("outerHTML")) { buttonOrLinkElem.Click(); this.WaitUntil(Criteria.MyDashboardPage.TotalCreditsAppliedValueLblVisible); return(null); } } if (Browser.Exists(Bys.MyDashboardPage.ViewMoreBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == ViewMoreBtn.GetAttribute("outerHTML")) { buttonOrLinkElem.Click(); MyHoldingAreaPage page = new MyHoldingAreaPage(Browser); page.WaitForInitialize(); return(page); } } else { throw new Exception("No button or link was found with your passed parameter. You either need to add this button to a new If statement, " + "or if the button is already added, then the page you were on did not contain the button."); } return(null); }