public void ATC4439_ClientAlertsValidation()
        {
            //Login in as role
            User user = this.environment.GetUser(SecurityRole.Investigations);
            new LoginDialog().Login(user.Id, user.Password);

            //Navigate to: Client Services group > Clients tile
            HomePage homePage = new HomePage(driver);
            homePage.HoverCRMRibbonTab();
            homePage.ClickClientServicesRibbonButton();
            homePage.HoverClientServicesRibbonTab();
            homePage.ClickClientsRibbonButton();

            //Double-click on a Organisation record.
            ClientsSearchPage clientsSearchPage = new ClientsSearchPage(driver);
            clientsSearchPage.ClickNewClientButton();

            ClientPage clientPage = new ClientPage(driver);
            clientPage.ClickPageTitle();

            clientPage.SetClientType("Organisation");
            clientPage.SetOrganizationName("TC AlertValidation");
            clientPage.ClickSaveButton();
            string clientID = clientPage.GetClientID();
            clientPage.ClickSaveCloseButton();

            clientsSearchPage = new ClientsSearchPage(driver);
            clientsSearchPage.SetClientSearchText(clientID);

            Table table = new Table(clientsSearchPage.GetSearchResultTable());
            table.ClickCellValue("RTA Client Id", clientID, "Full Name");

            //Inspect Current Alerts section.Click [+] button.
            clientPage = new ClientPage(driver);
            clientPage.ClickPageTitle();
            string BaseWindow = driver.CurrentWindowHandle;
            clientPage.ClickAddAlertElement();

            //Set {Alert Type} to 'Other'.{Other Alert} field becomes mandatory and is enabled.
            driver = UICommon.SwitchToNewBrowserWithTitle(driver, BaseWindow, "Alert");
            AlertPage alertPage = new AlertPage(driver);
            alertPage.SetAlertTypeElement("Other");
            Assert.IsTrue(alertPage.VerifyOtherAlertMandatoryFieldIconPresent());

            //Enter free text into {Other Alert} field and {Description}.
            alertPage.SetOtherAlertText("Other Alert One");
            alertPage.SetDesctiptionText("Description Text Test Value One");

            //Saved.Displays as current alert.As per entered.
            alertPage.ClickSaveCloseIMG();
            driver = driver.SwitchTo().Window(BaseWindow);
            clientPage = new ClientPage(driver);

            Table alertTable = new Table(clientPage.GetCurrentAlertsTable());
            StringAssert.Contains(alertTable.GetCellValue("Other Alert", "Other Alert One", "Alert Type"),"Other","Validating whether other alert displayed in current alerts");

            BaseWindow = driver.CurrentWindowHandle;
            //Create another Alert:Set {Start date}.Set {End date} to today.Save record.
            clientPage.ClickAddAlertElement();
            Thread.Sleep(5000);

            driver = UICommon.SwitchToNewBrowserWithTitle(driver, BaseWindow, "Alert");
            alertPage = new AlertPage(driver);
            alertPage.SetAlertTypeElement("Other");

            Assert.IsTrue(alertPage.VerifyOtherAlertMandatoryFieldIconPresent());

            alertPage.SetOtherAlertText("Other Alert Two");
            alertPage.SetDesctiptionText("Description Text Test Value Two");
            alertPage.SetStartDateValue(DateTime.Now.ToString("dd/MM/yyyy"));
            alertPage.SetEndDateValue(DateTime.Now.ToString("dd/MM/yyyy"));

            alertPage.ClickSaveCloseIMG();
            driver.SwitchTo().Window(BaseWindow);

            //Saved.Displays as current alert.As per entered.
            clientPage = new ClientPage(driver);
            alertTable = new Table(clientPage.GetCurrentAlertsTable());
            StringAssert.Contains(alertTable.GetCellValue("Other Alert", "Other Alert Two", "Alert Type"), "Other", "Validating whether other alert displayed in current alerts");

            //Modify record:Set {End date} to yesterday.Save record.
            IWebElement alertElement = alertTable.GetCellElementContainsValue("Other Alert", "Other Alert Two", "Other Alert");
            UICommon.DoubleClickElement(alertElement, driver);

            alertPage = new AlertPage(driver);
            alertPage.SetStartDateValue(DateTime.Now.AddDays(-1).ToString("dd/MM/yyyy"));
            alertPage.SetEndDateValue(DateTime.Now.AddDays(-1).ToString("dd/MM/yyyy"));
            alertPage.ClickSaveCloseIMG();

            //Saved.NOT displayed as current alert.As per entered.
            clientPage = new ClientPage(driver);
            alertTable = new Table(clientPage.GetCurrentAlertsTable());
            Assert.IsFalse(alertTable.MatchingCellFound("Other Alert","Other Alert Two"), "Validating the alert with end date as yeterday not displayed in current alerts");

            //Create more then four current Alerts.
            BaseWindow = driver.CurrentWindowHandle;
            clientPage.ClickAddAlertElement();
            Thread.Sleep(3000);

            driver = UICommon.SwitchToNewBrowserWithTitle(driver, BaseWindow, "Alert");
            alertPage = new AlertPage(driver);
            alertPage.SetAlertTypeElement("Other");

            Assert.IsTrue(alertPage.VerifyOtherAlertMandatoryFieldIconPresent());

            alertPage.SetOtherAlertText("Other Alert Two");
            alertPage.SetDesctiptionText("Description Text Test Value Two");
            alertPage.SetStartDateValue(DateTime.Now.ToString("dd/MM/yyyy"));
            alertPage.SetEndDateValue(DateTime.Now.ToString("dd/MM/yyyy"));

            alertPage.ClickSaveCloseIMG();
            driver = driver.SwitchTo().Window(BaseWindow);

            clientPage = new ClientPage(driver);
            clientPage.ClickPageTitle();

            BaseWindow = driver.CurrentWindowHandle;
            clientPage.ClickAddAlertElement();
            Thread.Sleep(3000);

            //Enter Alert details
            driver = UICommon.SwitchToNewBrowserWithTitle(driver, BaseWindow, "Alert");
            alertPage = new AlertPage(driver);
            alertPage.SetAlertTypeElement("Other");

            Assert.IsTrue(alertPage.VerifyOtherAlertMandatoryFieldIconPresent());

            alertPage.SetOtherAlertText("Other Alert Three");
            alertPage.SetDesctiptionText("Description Text Test Value Three");
            alertPage.SetStartDateValue(DateTime.Now.ToString("dd/MM/yyyy"));
            alertPage.SetEndDateValue(DateTime.Now.ToString("dd/MM/yyyy"));

            alertPage.ClickSaveCloseIMG();

            driver = driver.SwitchTo().Window(BaseWindow);

            clientPage = new ClientPage(driver);
            clientPage.ClickPageTitle();
            BaseWindow = driver.CurrentWindowHandle;
            clientPage.ClickAddAlertElement();
            Thread.Sleep(3000);

            //Enter Alert details
            driver = UICommon.SwitchToNewBrowserWithTitle(driver, BaseWindow, "Alert");
            alertPage = new AlertPage(driver);
            alertPage.SetAlertTypeElement("Other");

            Assert.IsTrue(alertPage.VerifyOtherAlertMandatoryFieldIconPresent());

            alertPage.SetOtherAlertText("Other Alert Four");
            alertPage.SetDesctiptionText("Description Text Test Value Four");
            alertPage.SetStartDateValue(DateTime.Now.ToString("dd/MM/yyyy"));
            alertPage.SetEndDateValue(DateTime.Now.ToString("dd/MM/yyyy"));

            alertPage.ClickSaveCloseIMG();
            driver = driver.SwitchTo().Window(BaseWindow);

            //Section is dynamic and allows for multi-page display.
            clientPage = new ClientPage(driver);
            clientPage.ClickPageTitle();
            clientPage.ClickNextPageAlertTable();

            alertTable = new Table(clientPage.GetCurrentAlertsTable());
            Assert.IsTrue(alertTable.MatchingCellFound("Other Alert", "Other Alert Four"), "Validating the fourth alert displayed in the next page of alert table");
        }
        public void ATC4407_CRMAlertsValidationforClient()
        {
            #region Start Up Excel
            MyBook = MyApp.Workbooks.Open(DatasourceDir + @"\Clients.xlsx", 0, false, 5, "", "", true, Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
            MySheet = (Excel.Worksheet)MyBook.Sheets[Properties.Settings.Default.ENVIRONMENT.ToString()];
            MyRange = MySheet.UsedRange;

            //Get specific row for the data
            int testDataRows = MyRange.Rows.Count;
            int MyRow = 0;
            for (int i = 2; i <= testDataRows; i++)
            {
                if (MyRange.Cells[i, 1].Value.ToString() == "ClientTestData")
                {
                    MyRow = i;
                    break;
                }
            }
            #endregion

            string clientName = (MyRange.Cells[MyRow, ClientsSchema.GetColumnIndex("CLIENT_NAME")].Value.ToString());

            //Login in as role
            User user = this.environment.GetUser(SecurityRole.GeneralStaff);
            new LoginDialog().Login(user.Id, user.Password);

            HomePage homePage = new HomePage(driver);
            homePage.HoverCRMRibbonTab();
            homePage.ClickClientServicesRibbonButton();
            homePage.HoverClientServicesRibbonTab();
            homePage.ClickClientsRibbonButton();

            ClientsSearchPage clientsSearchPage = new ClientsSearchPage(driver);
            string testName = clientName;
            clientsSearchPage.SetClientSearchText(testName);
            Table table = new Table(clientsSearchPage.GetSearchResultTable());
            table.ClickCellValue("Full Name", testName, "Full Name");

            ClientPage clientPage = new ClientPage(driver);
            clientPage.ClickPageTitle();
            string BaseWindow = driver.CurrentWindowHandle;

            clientPage.ClickAddAlertElement();

            //Enter Alert details
            driver = UICommon.SwitchToNewBrowserWithTitle(driver, BaseWindow, "Alert");
            AlertPage alertPage = new AlertPage(driver);
            Assert.IsTrue(alertPage.GetAlertTypeText("Other"));

            alertPage.SetOtherAlertText("Other Alert Test Value");
            alertPage.SetDesctiptionText("Description Text Test Value");

            alertPage.ClickSaveIMG();
            StringAssert.Contains(alertPage.GetAlertNumber(), testName);

            Assert.IsTrue(alertPage.GetAlertTypeText("Receivership/Management"));

            //Assert that Other Alert is locked
            string controlMode = alertPage.GetOtherAlertControlMode();
            StringAssert.Equals(controlMode, "locked");
            alertPage.SetStartDateValue(DateTime.Now.ToString("dd/MM/yyyy"));
            alertPage.SetEndDateValue(DateTime.Now.ToString("dd/MM/yyyy"));
            alertPage.ClickSaveIMG();
            //Assert.IsTrue(alertPage.GetNoErrorMessageState());
            StringAssert.Contains(alertPage.GetAlertState(), "Active");

            alertPage.SetEndDateValue(DateTime.Now.AddDays(1).ToString("dd/MM/yyyy"));
            alertPage.ClickSaveIMG();
            //Assert.IsTrue(alertPage.GetNoErrorMessageState());

            alertPage.SetEndDateValue(DateTime.Now.AddDays(-1).ToString("dd/MM/yyyy"));
            alertPage.ClickSaveIMG();
            StringAssert.Contains(alertPage.GetStartDateErrorText(), "Start date must be earlier than or the same as end date");
            alertPage.ClickPageTitle();
            //alertPage.ClickStartDate();
            alertPage.SetStartDateValue(DateTime.Now.AddDays(-1).ToString("dd/MM/yyyy"));
            alertPage.ClickSaveIMG();
            //Assert.IsTrue(alertPage.GetNoErrorMessageState());

            alertPage.ClickDeactivateIMG();
            StringAssert.Contains(alertPage.GetAlertState(), "Inactive");
            driver.Close();
            driver.SwitchTo().Window(BaseWindow);

            #region Shut down Excel
            MyBook.Save();
            MyBook.Close();
            MyApp.Quit();
            #endregion
        }