/// <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 element to click on</param> public void 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.PERTraineePage.BackToDashboardBtn)) { // This is a workaround to be able to use an IF statement on an IWebElement type. if (buttonOrLinkElem.GetAttribute("outerHTML") == BackToDashboardBtn.GetAttribute("outerHTML")) { ElemSet.ClickAfterScroll(Browser, buttonOrLinkElem); this.WaitUntilAny(TimeSpan.FromSeconds(180), Criteria.PERTraineePage.MilestonesTblMilestoneNameLinksEnabled, Criteria.PERTraineePage.SubmitPortfolioBtnVisible, Criteria.PERTraineePage.ReviewStageValueLblHasText); return; } } if (Browser.Exists(Bys.PERTraineePage.MilestonesInMilestonesTblLnks)) { // This is a workaround to be able to use an IF statement on an IWebElement type. if (buttonOrLinkElem.GetAttribute("outerHTML") == MilestonesInMilestonesTblLnks[0].GetAttribute("outerHTML")) { ElemSet.ClickAfterScroll(Browser, buttonOrLinkElem); this.WaitUntilAll(Criteria.PERTraineePage.EvidenceTblUpdateLinksEnabledAndVisible, Criteria.PERTraineePage.BackToDashboardBtnVisible); return; } } if (Browser.Exists(Bys.PERTraineePage.ResubmitBtn)) { // This is a workaround to be able to use an IF statement on an IWebElement type. if (buttonOrLinkElem.GetAttribute("outerHTML") == ResubmitBtn.GetAttribute("outerHTML")) { ElemSet.ClickAfterScroll(Browser, buttonOrLinkElem); this.WaitUntilAll(Criteria.PERTraineePage.ReviewStageValueLblHasText); return; } } if (Browser.Exists(Bys.PERTraineePage.EvidForAchieveFormCloseLnk)) { // This is a workaround to be able to use an IF statement on an IWebElement type. if (buttonOrLinkElem.GetAttribute("outerHTML") == EvidForAchieveFormCloseLnk.GetAttribute("outerHTML")) { ElemSet.ClickAfterScroll(Browser, buttonOrLinkElem); this.WaitUntil(Criteria.PERTraineePage.UploadedFileLnkVisible); return; } } if (Browser.Exists(Bys.PERTraineePage.YourReplySaveChangesBtn)) { // This is a workaround to be able to use an IF statement on an IWebElement type. if (buttonOrLinkElem.GetAttribute("outerHTML") == YourReplySaveChangesBtn.GetAttribute("outerHTML")) { ElemSet.ClickAfterScroll(Browser, buttonOrLinkElem); // Add a better wait here. Note that waiting for the save changes button to not be visible doesnt work for some reason Thread.Sleep(2000); return; } } if (Browser.Exists(Bys.PERTraineePage.DescriptionSaveChangesBtn)) { // This is a workaround to be able to use an IF statement on an IWebElement type. if (buttonOrLinkElem.GetAttribute("outerHTML") == DescriptionSaveChangesBtn.GetAttribute("outerHTML")) { ElemSet.ClickAfterScroll(Browser, buttonOrLinkElem); this.WaitUntilAll(Criteria.PERTraineePage.DescriptionSaveChangesButtonNotVisible); return; } } if (Browser.Exists(Bys.PERTraineePage.MarkCompleteBtn)) { // This is a workaround to be able to use an IF statement on an IWebElement type. if (buttonOrLinkElem.GetAttribute("outerHTML") == MarkCompleteBtn.GetAttribute("outerHTML")) { ElemSet.ClickAfterScroll(Browser, buttonOrLinkElem); this.WaitUntilAll(Criteria.PERTraineePage.MarkCompleteButtonNotVisible); return; } } if (Browser.Exists(Bys.PERTraineePage.SubmitPortfolioFormSubmitBtn)) { // This is a workaround to be able to use an IF statement on an IWebElement type. if (buttonOrLinkElem.GetAttribute("outerHTML") == SubmitPortfolioFormSubmitBtn.GetAttribute("outerHTML")) { ElemSet.ClickAfterScroll(Browser, buttonOrLinkElem); this.WaitUntilAll(Criteria.PERTraineePage.SubmitPortfolioFormSubmitBtnNotVisible); return; } } if (Browser.Exists(Bys.PERTraineePage.SubmitPortfolioBtn)) { // This is a workaround to be able to use an IF statement on an IWebElement type. if (buttonOrLinkElem.GetAttribute("outerHTML") == SubmitPortfolioBtn.GetAttribute("outerHTML")) { ElemSet.ClickAfterScroll(Browser, buttonOrLinkElem); this.WaitUntilAll(Criteria.PERTraineePage.SubmitPortfolioFormSubmitBtnVisible); return; } } 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."); } }
/// <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 void 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.DiplomaAssessorPage.BackToDashboardBtn)) { // This is a workaround to be able to use an IF statement on an IWebElement type. if (buttonOrLinkElem.GetAttribute("outerHTML") == BackToDashboardBtn.GetAttribute("outerHTML")) { buttonOrLinkElem.Click(); this.WaitUntil(Criteria.DiplomaAssessorPage.MilestonesTblEnabled); Thread.Sleep(0200); return; } } if (Browser.Exists(Bys.DiplomaAssessorPage.RequestAdditionalInfoBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == RequestAdditionalInfoBtn.GetAttribute("outerHTML")) { buttonOrLinkElem.Click(); this.WaitUntil(Criteria.DiplomaAssessorPage.RequestAdditionalInfoFormSubmitBtnVisible); return; } } if (Browser.Exists(Bys.DiplomaAssessorPage.RequestAdditionalInfoFormSubmitBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == RequestAdditionalInfoFormSubmitBtn.GetAttribute("outerHTML")) { buttonOrLinkElem.Click(); this.WaitUntil(Criteria.DiplomaAssessorPage.ReviewStageValueLblVisible); Thread.Sleep(1000); return; } } if (Browser.Exists(Bys.DiplomaAssessorPage.MarkAsAchievedFormSubmitBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == MarkAsAchievedFormSubmitBtn.GetAttribute("outerHTML")) { buttonOrLinkElem.Click(); this.WaitUntil(Criteria.DiplomaAssessorPage.MilestonesTblEnabled); Thread.Sleep(0300); return; } } if (Browser.Exists(Bys.DiplomaAssessorPage.MarkAsNotAchievedFormSubmitBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == MarkAsNotAchievedFormSubmitBtn.GetAttribute("outerHTML")) { buttonOrLinkElem.Click(); this.WaitUntil(Criteria.DiplomaAssessorPage.MilestonesTblEnabled); Thread.Sleep(0300); return; } } if (Browser.Exists(Bys.DiplomaAssessorPage.MarkAsAchievedBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == MarkAsAchievedBtn.GetAttribute("outerHTML")) { buttonOrLinkElem.Click(); this.WaitUntil(Criteria.DiplomaAssessorPage.MarkAsAchievedFormSubmitBtnVisible); return; } } if (Browser.Exists(Bys.DiplomaAssessorPage.MarkAsNotAchievedBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == MarkAsNotAchievedBtn.GetAttribute("outerHTML")) { buttonOrLinkElem.Click(); this.WaitUntilAny(Criteria.DiplomaAssessorPage.MarkAsNotAchievedFormSubmitBtnVisible); return; } } 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."); } }
/// <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 void 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.DiplomaTraineePage.BackToDashboardBtn)) { // This is a workaround to be able to use an IF statement on an IWebElement type. if (buttonOrLinkElem.GetAttribute("outerHTML") == BackToDashboardBtn.GetAttribute("outerHTML")) { ElemSet.ClickAfterScroll(Browser, buttonOrLinkElem); this.WaitUntil(Criteria.DiplomaTraineePage.MainFrameVisibleAndEnabled); Browser.SwitchTo().Frame(MainFrame); this.WaitUntil(Criteria.DiplomaTraineePage.MilestonesTblVisible); return; } } if (Browser.Exists(Bys.DiplomaTraineePage.SubmitMilestoneFormSubmitBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == SubmitMilestoneFormSubmitBtn.GetAttribute("outerHTML")) { ElemSet.ClickAfterScroll(Browser, buttonOrLinkElem); this.WaitUntil(Criteria.DiplomaTraineePage.MainFrameVisibleAndEnabled); Browser.SwitchTo().Frame(MainFrame); this.WaitUntil(Criteria.DiplomaTraineePage.MilestonesTblVisible); return; } } if (Browser.Exists(Bys.DiplomaTraineePage.MilestonesInMilestonesTblLnks)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == MilestonesInMilestonesTblLnks[0].GetAttribute("outerHTML")) { ElemSet.ClickAfterScroll(Browser, buttonOrLinkElem); WaitForMilestoneFrame(); return; } } if (Browser.Exists(Bys.DiplomaTraineePage.ResubmitBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == ResubmitBtn.GetAttribute("outerHTML")) { ElemSet.ClickAfterScroll(Browser, buttonOrLinkElem); this.WaitUntil(Criteria.DiplomaTraineePage.MainFrameVisibleAndEnabled); Browser.SwitchTo().Frame(MainFrame); this.WaitUntil(Criteria.DiplomaTraineePage.MilestonesTblVisible); return; } } if (Browser.Exists(Bys.DiplomaTraineePage.EvidForAchieveFormDoneBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == EvidForAchieveFormDoneBtn.GetAttribute("outerHTML")) { ElemSet.ClickAfterScroll(Browser, buttonOrLinkElem); this.WaitUntil(Criteria.DiplomaTraineePage.UploadedFileLnkVisible); return; } } if (Browser.Exists(Bys.DiplomaTraineePage.YourReplySaveChangesBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == YourReplySaveChangesBtn.GetAttribute("outerHTML")) { ElemSet.ClickAfterScroll(Browser, buttonOrLinkElem); // Add a better wait here. Note that waiting for the save changes button to not be visible doesnt work for some reason Thread.Sleep(2000); return; } } if (Browser.Exists(Bys.DiplomaTraineePage.DescriptionSaveChangesBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == DescriptionSaveChangesBtn.GetAttribute("outerHTML")) { ElemSet.ClickAfterScroll(Browser, buttonOrLinkElem); this.WaitUntil(Criteria.DiplomaTraineePage.DescriptionSaveChangesButtonNotExists); return; } } if (Browser.Exists(Bys.DiplomaTraineePage.SubmitBtn)) { // Using offsetleft here instead of outerHTML because this button and SubmitPortfolioFormSubmitBtn have the same outerHTML if (buttonOrLinkElem.GetAttribute("offsetLeft") == SubmitBtn.GetAttribute("offsetLeft")) { ElemSet.ClickAfterScroll(Browser, buttonOrLinkElem); this.WaitUntil(Criteria.DiplomaTraineePage.SubmitMilestoneFormSelectReviewerSelElemIsVisibleHasItems); return; } } if (Browser.Exists(Bys.DiplomaTraineePage.SubmitPortfolioFormSubmitBtn)) { if (buttonOrLinkElem.GetAttribute("offsetLeft") == SubmitPortfolioFormSubmitBtn.GetAttribute("offsetLeft")) { ElemSet.ClickAfterScroll(Browser, buttonOrLinkElem); this.WaitUntil(Criteria.DiplomaTraineePage.SubmitPortfolioFormSubmitBtnNotVisible); return; } } if (Browser.Exists(Bys.DiplomaTraineePage.SubmitPortfolioBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == SubmitPortfolioBtn.GetAttribute("outerHTML")) { ElemSet.ClickAfterScroll(Browser, buttonOrLinkElem); this.WaitUntilAll(Criteria.DiplomaTraineePage.SubmitPortfolioFormSubmitBtnVisible); return; } } 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."); } }