public void ATC4448_CRMInvestigationVerifyFilterOnInvestigatorName()
        {
            #region Start Up Excel
            MyBook = MyApp.Workbooks.Open(DatasourceDir + @"\Investigations.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, InvestigationSchema.GetColumnIndex(ColumnName.CLIENT_NAME)].Value;

            //Login in as role
            User user = this.environment.GetUser(SecurityRole.Investigations);

            new LoginDialog().Login(user.Id, user.Password);

            HomePage homePage = new HomePage(driver);
            string HomeWindow = driver.CurrentWindowHandle;
            homePage.HoverCRMRibbonTab();
            homePage.ClickInvestigationsRibbonButton();
            homePage.HoverInvestigationsRibbonTab();
            homePage.ClickInvestigationsCasesRibbonButton();

            // Create investigation case 1 with Investigator as IMSTestU06"
            InvestigationCaseSearchPage investigationCaseSearchPage = new InvestigationCaseSearchPage(driver);
            string BaseWindow = driver.CurrentWindowHandle;
            investigationCaseSearchPage.ClickNewInvestigationCaseButton();

            InvestigationCasePage investigationCasePage = new InvestigationCasePage(driver);
            string user06 = "IMSTestU06";
            string user04 = "IMSTestU04";

            investigationCasePage.ClickPageTitle();
            Assert.IsTrue(investigationCasePage.GetInvestigatorSearchElementText(user06));
            investigationCasePage.ClickSaveButton();
            string investigationID1 = investigationCasePage.GetInvestigationCaseNumber();
            Console.WriteLine(investigationID1);
            investigationCasePage.ClickSaveCloseButton();

            // Create investigation case 2 with Investigator as IMSTestU06"
            driver = driver.SwitchTo().Window(BaseWindow);
            investigationCaseSearchPage.ClickNewInvestigationCaseButton();

            investigationCasePage = new InvestigationCasePage(driver);
            investigationCasePage.ClickPageTitle();
            Assert.IsTrue(investigationCasePage.GetInvestigatorSearchElementText(user06));
            investigationCasePage.ClickSaveButton();
            string investigationID2 = investigationCasePage.GetInvestigationCaseNumber();
            Console.WriteLine(investigationID2);
            investigationCasePage.ClickSaveCloseButton();
            Thread.Sleep(1000);

            // Create one general case where owner = same common investigator from above point
            driver = driver.SwitchTo().Window(HomeWindow);
            homePage.HoverInvestigationsRibbonTab();
            homePage.ClickInvestigationsGeneralCasesRibbonButton();

            InvestigationGeneralCaseSearchPage investigationsGeneralCasesPage = new InvestigationGeneralCaseSearchPage(driver);
            investigationsGeneralCasesPage.ClickNewGeneralCaseButton();

            InvestigationGeneralCasePage investigationGeneralCasePage = new InvestigationGeneralCasePage(driver);
            investigationGeneralCasePage.ClickPageTitle();
            investigationGeneralCasePage.SetTitle("Client D");
            investigationGeneralCasePage.SetClientName(clientName);
            investigationGeneralCasePage.SetType("Enquiry");
            investigationGeneralCasePage.SetInvestigatorSearchElementText(user06);
            investigationGeneralCasePage.ClickSaveButton();

            string generalCaseID = investigationGeneralCasePage.GetGeneralCaseNumber();
            Console.WriteLine(generalCaseID);
            investigationGeneralCasePage.ClickSaveCloseButton();

            // Ensure an investigation master case exists with the same common {Investigator} as above
            driver = driver.SwitchTo().Window(HomeWindow);
            homePage.HoverInvestigationsRibbonTab();
            homePage.ClickInvestigationsMasterCasesRibbonButton();

            InvestigationMasterCaseSearchPage investigationMasterCasesSearchPage = new InvestigationMasterCaseSearchPage(driver);
            investigationMasterCasesSearchPage.ClickNewButton();

            InvestigationMasterCasePage investigationMasterCasePage = new InvestigationMasterCasePage(driver);
            investigationMasterCasePage.SetInvestigatorValue(user06);
            investigationMasterCasePage.ClickSaveButton();
            string masterCasrID = investigationMasterCasePage.GetInvestigationMasterCaseNumber();
            Console.WriteLine(masterCasrID);
            // Close the current window and login with Investigation Business Admin
            driver.Close();
            driver = null;

            this.TestSetup();

            user = this.environment.GetUser(SecurityRole.InvestigationsBusinessAdmin);
            new LoginDialog().Login(user.Id, user.Password);

            // Verify the Support Officers queue
            homePage = new HomePage(driver);
            homePage.HoverCRMRibbonTab();
            homePage.ClickInvestigationsRibbonButton();
            homePage.HoverInvestigationsRibbonTab();
            homePage.ClickInvestigationsCasesRibbonButton();

            // Ensure at least one other investigations case exists with a different {Investigator} but {Owner} = same common investigator as above
            investigationCaseSearchPage = new InvestigationCaseSearchPage(driver);
            investigationCaseSearchPage.ClickNewInvestigationCaseButton();

            investigationCasePage = new InvestigationCasePage(driver);
            investigationCasePage.ClickPageTitle();

            Assert.IsTrue(investigationCasePage.GetInvestigatorSearchElementText(user04));
            investigationCasePage.ClickSaveButton();
            string investigationID3 = investigationCasePage.GetInvestigationCaseNumber();
            Console.WriteLine(investigationID3);
            investigationCasePage.ClickSaveCloseButton();

            investigationCaseSearchPage = new InvestigationCaseSearchPage(driver);
            investigationCaseSearchPage.SetSearchRecord("IMSTestU06");

            Table table = new Table(investigationCaseSearchPage.GetSearchResultTable());
            table.ClickCellContainsValue("Investigator", "IMSTestU06", "Investigator");

            // Verify that User oage is getting displayed
            UserPage investigationUserPage = new UserPage(driver);
            investigationUserPage.ClickPageTitle();
            StringAssert.Contains(investigationUserPage.GetFullName(), "IMSTestU06");

            //Navigate to client phone numbers
            homePage.HoverClientXRibbonTab(user06);
            homePage.ClickInvestigatorXCasesRibbonButton();

            // Verify the cases displayed for Investigation Business Admin
            investigationUserPage = new UserPage(driver);
            StringAssert.Contains(investigationUserPage.GetPageFilterList(), "Investigation Case Associated View");

            // Verify Investigation Case 1 is displayed
            investigationUserPage = new UserPage(driver);
            investigationUserPage.SetSearchRecord(investigationID1);
            table = new Table(investigationUserPage.GetSearchResultTable());
            StringAssert.Contains(table.GetCellContainsValue("Case Number", investigationID1, "Investigator"), user06);
            StringAssert.Contains(table.GetCellContainsValue("Case Number", investigationID1, "Owner"), user04);

            // Verify Investigation Case 2 is displayed
            investigationUserPage = new UserPage(driver);
            investigationUserPage.SetSearchRecord(investigationID2);
            table = new Table(investigationUserPage.GetSearchResultTable());
            StringAssert.Contains(table.GetCellContainsValue("Case Number", investigationID2, "Investigator"), user06);
            StringAssert.Contains(table.GetCellContainsValue("Case Number", investigationID2, "Owner"), user04);

            // Verify General case is not displayed
            investigationUserPage = new UserPage(driver);
            investigationUserPage.SetSearchRecord(generalCaseID);
            table = new Table(investigationUserPage.GetSearchResultTable());
            Assert.IsTrue(table.GetNoRecordsInTable(), "General case is DISPLAYED!!!!");

            // Verify Master case is not displayed
            investigationUserPage = new UserPage(driver);
            investigationUserPage.SetSearchRecord(masterCasrID);
            table = new Table(investigationUserPage.GetSearchResultTable());
            Assert.IsTrue(table.GetNoRecordsInTable(), "Master case is DISPLAYED!!!!");

            // Verify Master case is not displayed
            investigationUserPage = new UserPage(driver);
            investigationUserPage.SetSearchRecord(investigationID3);
            table = new Table(investigationUserPage.GetSearchResultTable());
            Assert.IsTrue(table.GetNoRecordsInTable(), "Investigation case with different Investigator is DISPLAYED!!!!");

            #region Shut down Excel
            MyBook.Save();
            MyBook.Close();
            MyApp.Quit();
            #endregion
        }
        public void ATC3351_CRMEntityClientNameCreateNewWithInformation()
        {
            #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());
            string EmailID = (MyRange.Cells[MyRow, ClientsSchema.GetColumnIndex("EMAIL")].Value.ToString());

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

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

            ClientsSearchPage clientsSearchPage = new ClientsSearchPage(driver);
            clientsSearchPage.ClickNewClientButton();

            // Add new client name
            ClientPage clientPage = new ClientPage(driver);

            // Fill in mandatory fields
            clientPage.PopulateNewClient(clientName);

            // Fill in Email address
            clientPage.SetEmail1ID(EmailID);
            clientPage.ClickSaveButton();
            string BaseWindow = driver.CurrentWindowHandle;

            // Set the postal address
            clientPage.ClickCreateNewClientAddressButton("rta_physicaladdressid");

            driver = UICommon.SwitchToNewBrowserWithTitle(driver, BaseWindow, "Client Address");

            ClientNewAddressPage clientNewAddressPage = new ClientNewAddressPage(driver);
            clientNewAddressPage.SetAddressDetails("Australian Physical", 10, "GRACELAND");

            driver.SwitchTo().Window(BaseWindow);
            clientPage = new ClientPage(driver);

            //Verify Address value
            Assert.AreEqual("10 GRACELAND", clientPage.GetAddressValue("rta_physicaladdressid"));

            // Navigate to client phone numbers
            driver.SwitchTo().Window(HomeWindow);
            homePage.HoverClientXRibbonTab(clientName);
            homePage.ClickClientXPhoneNumbersRibbonButton();
            clientPage = new ClientPage(driver);
            BaseWindow = driver.CurrentWindowHandle;

            clientPage.ClickAddNewClientPhoneImage();

            driver = UICommon.SwitchToNewBrowserWithTitle(driver, BaseWindow, "Client Phone Number");

            ClientPhoneNumberPage clientPhoneNumberPage = new ClientPhoneNumberPage(driver);
            //clientPhoneNumberPage.ClickTypeList();
            clientPhoneNumberPage.SetTypeListValue("Fixed Line");
            //clientPhoneNumberPage.ClickAreaCodeElement();
            clientPhoneNumberPage.SetAreaCodeValue("07");
            //clientPhoneNumberPage.ClickPhoneNumberElement();
            clientPhoneNumberPage.SetPhoneNumberValue("11111111");
            clientPhoneNumberPage.ClickSaveCloseButton();

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

            clientPage.SetClientSearchText(clientName);
            Table table = new Table(clientPage.GetSearchResultTable());

            StringAssert.Contains(table.GetCellValue("Client", clientName, "Full Phone Number"), "+61 7 1111 1111");

            #region Shut down Excel
            MyBook.Save();
            MyBook.Close();
            MyApp.Quit();
            #endregion
        }
        public void ATC3288_CRMEntityConnectionCreateactiveclientconnections()
        {
            //Login in as role
            User user = this.environment.GetUser(SecurityRole.Investigations);
            new LoginDialog().Login(user.Id, user.Password);

            HomePage homePage = new HomePage(driver);
            homePage.HoverCRMRibbonTab();
            homePage.ClickInvestigationsRibbonButton();
            homePage.HoverInvestigationsRibbonTab();
            homePage.ClickInvestigationsClientRibbonButton();

            ClientsSearchPage clientsSearchPage = new ClientsSearchPage(driver);
            clientsSearchPage.SetClientSearchText("BLAIR TEST");

            Table table = new Table(clientsSearchPage.GetSearchResultTable());
            table.ClickCellValue("Full Name", "BLAIR TEST","Full Name");

            homePage.HoverClientXRibbonTab("BLAIR TEST");
            homePage.ClickClientXConnectionsRibbonButton();

            ClientPage clientPage = new ClientPage(driver);
            string BaseWindow = driver.CurrentWindowHandle;
            clientPage.SetConnectList("To Another");

            driver = clientPage.SwitchNewBrowser(driver, BaseWindow, "Connection");

            ConnectionPage connectionsPage = new ConnectionPage(driver);
            connectionsPage.ClickPageTitle();
            connectionsPage.SetNameText("BLAIR TEST");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Bankrupt");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Child");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Co Owner");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Colleague");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Co-Tenant");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Employee");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Employer");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("External Agency");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Former Employer");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Friend");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Licensee/Business Owner");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Neighbour");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("On Site Manager");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Owner/Lessor");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Parent");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Partner");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Potential Duplicate");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Primary Case");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Process Failure");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Property Manager");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Receiver");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Referral");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Referred by");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Related case");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Resident");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Spouse");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Stakeholder");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Tenant");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Witness");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Managing Party");

            connectionsPage.SetStartDate("01/01/2015");
            connectionsPage.SetEndDate("01/02/2015");
            connectionsPage.SetDesctiptionText("Test description text");

            connectionsPage.ClickSaveIMG();

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

            clientPage = new ClientPage(driver);
            clientPage.ClickPageTitle();
            clientPage.SetClientSearchText("BLAIR TEST");

            table = new Table(clientPage.GetSearchResultTable());
            StringAssert.Contains(table.GetCellValue("Connected To", "BLAIR TEST", "Role (To)"), "Managing Party");
        }
        public void ATC3338_CRMClientFilterPhoneNumbers()
        {
            //Login in as role
            User user = this.environment.GetUser(SecurityRole.GeneralStaff);
            new LoginDialog().Login(user.Id, user.Password);
            string clientName = "FILTER PHONE" + UICommon.GetRandomString(3);

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

            ClientsSearchPage clientsSearchPage = new ClientsSearchPage(driver);
            clientsSearchPage.ClickNewClientButton();
            ClientPage clientPage = new ClientPage(driver);
            clientPage.ClickPageTitle();
            clientPage.SetFamilyName(clientName);
            //clientPage.PopulateNewClient(clientName);
            clientPage.ClickSaveButton();

            //Navigate to client phone numbers
            driver = driver.SwitchTo().Window(HomeWindow);
            homePage.HoverClientXRibbonTab(clientName);
            homePage.ClickClientXPhoneNumbersRibbonButton();

            //Add new phone numbers
            clientPage = new ClientPage(driver);
            string BaseWindow = driver.CurrentWindowHandle;
            clientPage.ClickAddNewClientPhoneImage();

            //Enter payment reference details
            driver = UICommon.SwitchToNewBrowserWithTitle(driver, BaseWindow, "Client Phone Number");

            //Assert availability list
            ClientPhoneNumberPage clientPhoneNumberPage = new ClientPhoneNumberPage(driver);

            //Create Fixed Line Number
            //clientPhoneNumberPage.ClickTypeList();
            clientPhoneNumberPage.SetTypeListValue("Fixed Line");
            //clientPhoneNumberPage.ClickAreaCodeElement();
            clientPhoneNumberPage.SetAreaCodeValue("07");
            //clientPhoneNumberPage.ClickPhoneNumberElement();
            clientPhoneNumberPage.SetPhoneNumberValue("11111111");
            clientPhoneNumberPage.ClickSaveButton();
            //Assert new phone number has saved
            string FixedLineNumber = clientPhoneNumberPage.GetPhoneNumber();

            clientPhoneNumberPage.ClickNewButton();
            clientPhoneNumberPage.ClickPageTitle();
            clientPhoneNumberPage.SetClientNameList(clientName);
            //clientPhoneNumberPage.ClickTypeList();
            clientPhoneNumberPage.SetTypeListValue("Mobile");
            //clientPhoneNumberPage.ClickPhoneNumberElement();
            clientPhoneNumberPage.SetPhoneNumberValue("0422222222");
            clientPhoneNumberPage.ClickSaveButton();
            //Assert new phone number has saved
            string MobileNumber = clientPhoneNumberPage.GetPhoneNumber();

            clientPhoneNumberPage.ClickNewButton();
            clientPhoneNumberPage.ClickPageTitle();
            clientPhoneNumberPage.SetClientNameList(clientName);
            //clientPhoneNumberPage.ClickTypeList();
            clientPhoneNumberPage.SetTypeListValue("Fax");
            //clientPhoneNumberPage.ClickAreaCodeElement();
            clientPhoneNumberPage.SetAreaCodeValue("07");
            //clientPhoneNumberPage.ClickPhoneNumberElement();
            clientPhoneNumberPage.SetPhoneNumberValue("33333333");
            clientPhoneNumberPage.ClickSaveButton();
            //Assert new phone number has saved
            string FaxNumber =  clientPhoneNumberPage.GetPhoneNumber();

            clientPhoneNumberPage.ClickNewButton();
            clientPhoneNumberPage.ClickPageTitle();
            clientPhoneNumberPage.SetClientNameList(clientName);
            //clientPhoneNumberPage.ClickTypeList();
            clientPhoneNumberPage.SetTypeListValue("Pager");
            //clientPhoneNumberPage.ClickAreaCodeElement();
            clientPhoneNumberPage.SetAreaCodeValue("07");
            //clientPhoneNumberPage.ClickPhoneNumberElement();
            clientPhoneNumberPage.SetPhoneNumberValue("44444444");
            clientPhoneNumberPage.ClickSaveButton();
            //Assert new phone number has saved
            string PagerNumber =clientPhoneNumberPage.GetPhoneNumber();

            clientPhoneNumberPage.ClickSaveCloseButton();
            clientPhoneNumberPage.ClickSaveCloseButton();
            clientPhoneNumberPage.ClickSaveCloseButton();
            clientPhoneNumberPage.ClickSaveCloseButton();

            driver = driver.SwitchTo().Window(HomeWindow);
            homePage.ClickClientXRibbonTab(clientName);
            clientPage = new ClientPage(driver);

            // Select Personal Mobile field -> only mobile phone number for client can be selected
            clientPage.ClickPageTitle();
            clientPage.OpenMobileNumbeDropDown();
            Assert.IsTrue(clientPage.VerifyMobileNumberOptionPresent(MobileNumber), "Mobile Phone number seen for Personal Mobile Field !!!");
            Assert.IsFalse(clientPage.VerifyMobileNumberOptionPresent(FixedLineNumber), "Fixed Line number seen for Personal Mobile Field !!!");
            Assert.IsFalse(clientPage.VerifyMobileNumberOptionPresent(FaxNumber), "Fax number seen for Personal Mobile Field !!!");
            Assert.IsFalse(clientPage.VerifyMobileNumberOptionPresent(PagerNumber), "Pager number seen for Personal Mobile Field !!!");

            // Personal Preferred field -> only mobile,fax, fixed line or pager phone number for client can be selected
            clientPage.ClickPageTitle();
            clientPage.OpenPersonalPreferredNumbeDropDown();
            Assert.IsTrue(clientPage.VerifyPersonalPreferredNumberOptionPresent(MobileNumber), "Mobile Phone number NOT seen for Personal Preferred field !!!");
            Assert.IsTrue(clientPage.VerifyPersonalPreferredNumberOptionPresent(FixedLineNumber), "Fixed Line number NOT seen for Personal Preferred field !!!");
            Assert.IsTrue(clientPage.VerifyPersonalPreferredNumberOptionPresent(FaxNumber), "Fax number NOT seen for Personal Preferred field !!!");
            Assert.IsTrue(clientPage.VerifyPersonalPreferredNumberOptionPresent(PagerNumber), "Pager number NOT seen for Personal Preferred field !!!");

            // Work Preferred field -> only mobile,fax, fixed line or pager phone number for client can be selected
            clientPage.ClickPageTitle();
            clientPage.OpenWorkPreferredNumbeDropDown();
            Assert.IsTrue(clientPage.VerifyWorkPreferredOptionPresent(MobileNumber), "Mobile Phone number NOT seen for Work Preferred field !!!");
            Assert.IsTrue(clientPage.VerifyWorkPreferredOptionPresent(FixedLineNumber), "Fixed Line number NOT seen for Work Preferred field !!!");
            Assert.IsTrue(clientPage.VerifyWorkPreferredOptionPresent(FaxNumber), "Fax number NOT seen for Work Preferred field !!!");
            Assert.IsTrue(clientPage.VerifyWorkPreferredOptionPresent(PagerNumber), "Pager number NOT seen for Work Preferred field !!!");

            // Home / Main Phone field -> only mobile,fax, fixed line or pager phone number for client can be selected
            clientPage.ClickPageTitle();
            clientPage.OpenHomeMainPhoneNumbeDropDown();
            Assert.IsTrue(clientPage.VerifyHomeMainPhoneOptionPresent(MobileNumber), "Mobile Phone number NOT seen for Home / Main Phone field !!!");
            Assert.IsTrue(clientPage.VerifyHomeMainPhoneOptionPresent(FixedLineNumber), "Fixed Line number NOT seen for Home / Main Phone field !!!");
            Assert.IsTrue(clientPage.VerifyHomeMainPhoneOptionPresent(FaxNumber), "Fax number NOT seen for Home / Main Phone field !!!");
            Assert.IsTrue(clientPage.VerifyHomeMainPhoneOptionPresent(PagerNumber), "Pager number NOT seen for Home / Main Phone field !!!");

            // Fax field  -> only fax or fixed line phone number for client can be selected
            clientPage.ClickPageTitle();
            clientPage.OpenFaxPhoneNumbeDropDown();
            Assert.IsFalse(clientPage.VerifyFaxOptionPresent(MobileNumber), "Mobile Phone number seen for Fax field !!!");
            Assert.IsTrue(clientPage.VerifyFaxOptionPresent(FixedLineNumber), "Fixed Line number NOT seen for Fax field !!!");
            Assert.IsTrue(clientPage.VerifyFaxOptionPresent(FaxNumber), "Fax number NOT seen for Fax field !!!");
            Assert.IsFalse(clientPage.VerifyFaxOptionPresent(PagerNumber), "Pager number seen for Fax field !!!");
        }
        public void ATC3350_CRMEntityClientAddressCreateNew()
        {
            #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() == "3350")
                {
                    MyRow = i;
                    break;
                }
            }
            #endregion

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

            //Login in as role
            User user = this.environment.GetUser(SecurityRole.SystemAdministrator);
            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);

            Trace.Listeners.Add(new TextWriterTraceListener("TextWriterOutput.log", "myListener"));
            Trace.TraceInformation("Add New Address start:" + DateTime.Now.ToString("ddMMyyyyhhmmssffff"));
            Trace.Flush();

            clientsSearchPage.ClickNewClientButton();

            ClientPage clientPage = new ClientPage(driver);
            clientPage.ClickPageTitle();
            clientPage.SetClientType("Person");
            clientPage.SetFamilyName("TESTING ADDRESS");
            clientPage.ClickSaveButton();
            string clientID = clientPage.GetClientID();
            homePage.HoverClientXRibbonTab("TESTING ADDRESS");
            homePage.ClickClientXAddressesRibbonButton();
            string BaseWindow = driver.CurrentWindowHandle;

            clientPage = new ClientPage(driver);
            Thread.Sleep(3000);
            clientPage.ClickAddNewClientAddressImage();
            driver = clientPage.SwitchNewBrowser(driver, BaseWindow, "Client Address:");
            ClientNewAddressPage clientNewAddressPage = new ClientNewAddressPage(driver);
            clientNewAddressPage.ClickPageTitle();
            clientNewAddressPage.SetAddressDetails("*" + address);
            clientNewAddressPage.ClickSaveButton();
            clientNewAddressPage.GetCleintAddress();

            Trace.Listeners.Add(new TextWriterTraceListener("TextWriterOutput.log", "myListener"));
            Trace.TraceInformation("Add New Address End:" + DateTime.Now.ToString("ddMMyyyyhhmmssffff"));
            Trace.Flush();

            clientNewAddressPage.ClickSaveAndClose();

            driver = driver.SwitchTo().Window(BaseWindow);
            clientPage = new ClientPage(driver);
            clientPage.ClickPageTitle();
            clientPage = new ClientPage(driver);
            clientPage.SetPostalAddress("*" + address);
            clientPage.ClickSaveCloseButton();
            clientsSearchPage = new ClientsSearchPage(driver);
            clientsSearchPage.SetClientSearchText(clientID);
            Table table = new Table(clientsSearchPage.GetSearchResultTable());
            Assert.AreEqual(table.GetCellValue("RTA Client Id", clientID, "Postal Address"), address, "Address comparison failed");

            #region Shut down Excel
            MyBook.Save();
            MyBook.Close();
            MyApp.Quit();
            #endregion
        }
        public void ATC3349_CRMEntityClientIdentificationArtefactCreateNew()
        {
            //3349: Entity: Client Identification Artefact - Create New
            #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;
            System.Diagnostics.Debug.WriteLine("testDataRows Present: " + testDataRows.ToString());
            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());
            String ClientIdProvided = (MyRange.Cells[MyRow, ClientsSchema.GetColumnIndex("ID_PROVIDED")].Value.ToString());
            //Login in as role
            User user = this.environment.GetUser(SecurityRole.InvestigationsManager);
            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);

            clientsSearchPage.SetClientSearchText("BLAIR TEST");
            Table table = new Table(clientsSearchPage.GetSearchResultTable());

            StringAssert.Equals(table.GetCellValue("Full Name", "BLAIR TEST", "Full Name"), "BLAIR TEST");
            table.ClickCellValue("Full Name", "BLAIR TEST", "Full Name");
            //Navigate to Cient Name
            homePage.HoverClientXRibbonTab("BLAIR TEST");
            homePage.ClickClientXClientIdArtefactRibbonButton();

            //Add new Cient Name
            ClientPage clientPage = new ClientPage(driver);
            string BaseWindow = driver.CurrentWindowHandle;
            System.Diagnostics.Debug.WriteLine("BaseWindow handle :" + BaseWindow.ToString());
            clientPage.ClickAddNewClientIdArtefact();
            string Title = "Client Identification Artefact";

            driver = UICommon.SwitchToNewBrowserWithTitle(driver, BaseWindow, Title);
            //Populate Client Identification Artefact Page
            ClientIdentificationArtefactPage clientIdentificationArtefactPagePage = new ClientIdentificationArtefactPage(driver);
            clientIdentificationArtefactPagePage.SetClientIdProvided(ClientIdProvided);

            clientIdentificationArtefactPagePage.ClickSaveButton();
            string FormTitle_Expected = clientName.ToUpper() + ": " + ClientIdProvided;
            //Get the saved FormTitle Text which gets displayed on the screen after the record is saved.
            string FormTitle_Actual = clientIdentificationArtefactPagePage.GetFormTitle(ClientIdProvided);
            System.Diagnostics.Debug.WriteLine("FormTitle_Actual: " + FormTitle_Actual);
            System.Diagnostics.Debug.WriteLine("FormTitle_Expected: " + FormTitle_Expected);
            //Assert Client Identification Artefact has saved.
            Assert.IsTrue(FormTitle_Actual.Equals(FormTitle_Expected), "Actual Form Title does not match the expected (saved) value: " + FormTitle_Expected);
            //Save and close the Client Identification Artefact Page
            clientIdentificationArtefactPagePage.ClickSaveCloseButton();
        }
        public void ATC3348_CRMEntityClientNameCreateNew()
        {
            //3348: Entity: Client Name - Create New

            #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;
            System.Diagnostics.Debug.WriteLine("testDataRows Present: " + testDataRows.ToString());
            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());
            String Title = (MyRange.Cells[MyRow, ClientsSchema.GetColumnIndex("TITLE")].Value.ToString());
            String GivenName = (MyRange.Cells[MyRow, ClientsSchema.GetColumnIndex("GIVEN_NAME")].Value.ToString());
            //String MiddleName = "Jackie";
            String MiddleName = (MyRange.Cells[MyRow, ClientsSchema.GetColumnIndex("MIDDLE_NAME")].Value.ToString());

            String FamilyName = (MyRange.Cells[MyRow, ClientsSchema.GetColumnIndex("FAMILY_NAME")].Value.ToString());
            //String Suffix = "AM";
            String Suffix = (MyRange.Cells[MyRow, ClientsSchema.GetColumnIndex("SUFFIX")].Value.ToString());

            //Login in as role
            User user = this.environment.GetUser(SecurityRole.InvestigationsManager);
            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);

            clientsSearchPage.SetClientSearchText("BLAIR TEST");
            Table table = new Table(clientsSearchPage.GetSearchResultTable());

            StringAssert.Equals(table.GetCellValue("Full Name", "BLAIR TEST", "Full Name"), "BLAIR TEST");
            table.ClickCellValue("Full Name", "BLAIR TEST", "Full Name");
            //Navigate to Cient Name
            homePage.HoverClientXRibbonTab("BLAIR TEST");
            homePage.ClickClientXClientNamesRibbonButton();

            //Add new Cient Name
            ClientPage clientPage = new ClientPage(driver);
            string BaseWindow = driver.CurrentWindowHandle;
            System.Diagnostics.Debug.WriteLine("BaseWindow handle :" + BaseWindow.ToString());
            clientPage.ClickAddNewClientName();

            //*****************This needs to be moved out of here********************************************
            string NewWindow = ""; //prepares for the new window handle

            ReadOnlyCollection<string> handles = null;
            //Check for Alert Present
            System.Diagnostics.Debug.WriteLine("Check for Alert Present");
            try
            {
                if (driver.SwitchTo().Alert() != null) {
                    System.Diagnostics.Debug.WriteLine("Alert Present: " + driver.SwitchTo().Alert().Text);
                    System.Diagnostics.Debug.WriteLine("alert type: " + driver.SwitchTo().Alert().GetType().ToString());
                    driver.SwitchTo().Alert().Accept(); // prepares Selenium to handle alert
            }
            }
            catch (NoAlertPresentException)
            {
                // no alert message
                System.Diagnostics.Debug.WriteLine("No Alert Present");
            }

            //switch to new window
            //for some reason UICommon.SwitchToNewBrowser does not detect there is a new window, so I'll reinstate the old code below
            // generally the old code detects the new window in under 10 sec. However, UICommon.SwitchToNewBrowser runs for 30sec and fails to find the new window, although it should find it.
            //driver = UICommon.SwitchToNewBrowser(driver, BaseWindow);

            //Check for New Window Present
            for (int i = 1; i < 10; i++)
            {
                if (driver.WindowHandles.Count == 1)
                { Thread.Sleep(1000); }
                else { break; }
            }

            handles = driver.WindowHandles;
            System.Diagnostics.Debug.WriteLine("window handle count :" + handles.Count);
            foreach (string handle in handles)
            {
                System.Diagnostics.Debug.WriteLine("window handle :" + handle.ToString());
                var Handles = handle;
                if (BaseWindow != handle)
                {
                    NewWindow = handle;

                    driver = driver.SwitchTo().Window(NewWindow);
                    System.Diagnostics.Debug.WriteLine("SwitchTo() New Window: " + NewWindow.ToString());
                    break;
                }
            }

            //Populate Client Name Page
            ClientNamePage clientNamePage = new ClientNamePage(driver);

            //select Client Title
            //clientNamePage.ClickTitleList();
            clientNamePage.SetTitleListValue(Title);
            //clientNamePage.ClickGivenName();
            clientNamePage.SetGivenNameValue(GivenName);
            //clientNamePage.ClickMiddleName();
            clientNamePage.SetMiddleNameValue(MiddleName);
            //clientNamePage.ClickFamilyName();
            clientNamePage.SetFamilyNameValue(FamilyName);
            //clientNamePage.ClickSuffixList();
            clientNamePage.SetSuffixListValue(Suffix);
            clientNamePage.ClickSaveButton();
            //switch back to Client Name Page window. This may not be necessary as we are already there.
            //switch to new window
            //driver = UICommon.SwitchToNewBrowser(driver, BaseWindow);

            string FormTitle_Expected = Title + " " + GivenName + " " + MiddleName + " " + FamilyName + " " + Suffix;
            //string FormTitle_Expected = Title + " " + GivenName + " " + FamilyName;

            //Get the saved FormTitle Text which gets displayed on the screen after the record is saved.
            //string FormTitle = clientNamePage.GetFormTitle("MISS Jan Jackie Rivers AM");
            string FormTitle_Actual = clientNamePage.GetFormTitle();
            System.Diagnostics.Debug.WriteLine("FormTitle_Actual: " + FormTitle_Actual);
            System.Diagnostics.Debug.WriteLine("FormTitle_Expected: " + FormTitle_Expected);
            //Assert clientName has saved.
            Assert.IsTrue(FormTitle_Actual.Equals(FormTitle_Expected.ToUpper()), "Actual Form Title does not match the expected (saved) value: " + FormTitle_Expected.ToUpper());
            //Save and close the Client Name Page
            clientNamePage.ClickSaveCloseButton();
        }
        public void ATC5505_CRMClientUpdatePhoneNumbers()
        {
            //Login in as role
            User user = this.environment.GetUser(SecurityRole.GeneralStaff);
            new LoginDialog().Login(user.Id, user.Password);
            string clientName = "CLIENT PHONE" + UICommon.GetRandomString(3);

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

            ClientsSearchPage clientsSearchPage = new ClientsSearchPage(driver);
            clientsSearchPage.ClickNewClientButton();
            ClientPage clientPage = new ClientPage(driver);
            clientPage.ClickPageTitle();
            clientPage.SetFamilyName(clientName);
            //clientPage.PopulateNewClient(clientName);
            clientPage.ClickSaveButton();

            //Navigate to client phone numbers
            driver = driver.SwitchTo().Window(HomeWindow);
            homePage.HoverClientXRibbonTab(clientName);
            homePage.ClickClientXPhoneNumbersRibbonButton();

            //Add new phone numbers
            clientPage = new ClientPage(driver);
            string BaseWindow = driver.CurrentWindowHandle;
            clientPage.ClickAddNewClientPhoneImage();

            //Enter payment reference details
            driver = UICommon.SwitchToNewBrowserWithTitle(driver, BaseWindow, "Client Phone Number");

            //Assert availability list
            ClientPhoneNumberPage clientPhoneNumberPage = new ClientPhoneNumberPage(driver);

            //Create Fixed Line Number
            //clientPhoneNumberPage.ClickTypeList();
            clientPhoneNumberPage.SetTypeListValue("Fixed Line");
            //clientPhoneNumberPage.ClickAreaCodeElement();
            clientPhoneNumberPage.SetAreaCodeValue("07");
            //clientPhoneNumberPage.ClickPhoneNumberElement();
            clientPhoneNumberPage.SetPhoneNumberValue("11111111");
            clientPhoneNumberPage.ClickSaveButton();
            //Assert new phone number has saved
            string FixedLineNumber =  clientPhoneNumberPage.GetPhoneNumber();

            clientPhoneNumberPage.ClickNewButton();
            clientPhoneNumberPage.ClickPageTitle();
            clientPhoneNumberPage.SetClientNameList(clientName);
            //clientPhoneNumberPage.ClickTypeList();
            clientPhoneNumberPage.SetTypeListValue("Mobile");
            //clientPhoneNumberPage.ClickPhoneNumberElement();
            clientPhoneNumberPage.SetPhoneNumberValue("0422222222");
            clientPhoneNumberPage.ClickSaveButton();
            //Assert new phone number has saved
            string MobileNumber = clientPhoneNumberPage.GetPhoneNumber();

            clientPhoneNumberPage.ClickNewButton();
            clientPhoneNumberPage.ClickPageTitle();
            clientPhoneNumberPage.SetClientNameList(clientName);
            //clientPhoneNumberPage.ClickTypeList();
            clientPhoneNumberPage.SetTypeListValue("Fax");
            //clientPhoneNumberPage.ClickAreaCodeElement();
            clientPhoneNumberPage.SetAreaCodeValue("07");
            //clientPhoneNumberPage.ClickPhoneNumberElement();
            clientPhoneNumberPage.SetPhoneNumberValue("33333333");
            clientPhoneNumberPage.ClickSaveButton();
            //Assert new phone number has saved
            string FaxNumber =  clientPhoneNumberPage.GetPhoneNumber();

            clientPhoneNumberPage.ClickNewButton();
            clientPhoneNumberPage.ClickPageTitle();
            clientPhoneNumberPage.SetClientNameList(clientName);
            //clientPhoneNumberPage.ClickTypeList();
            clientPhoneNumberPage.SetTypeListValue("Pager");
            //clientPhoneNumberPage.ClickAreaCodeElement();
            clientPhoneNumberPage.SetAreaCodeValue("07");
            //clientPhoneNumberPage.ClickPhoneNumberElement();
            clientPhoneNumberPage.SetPhoneNumberValue("44444444");
            clientPhoneNumberPage.ClickSaveButton();
            //Assert new phone number has saved
            string PagerNumber =clientPhoneNumberPage.GetPhoneNumber();

            clientPhoneNumberPage.ClickSaveCloseButton();
            clientPhoneNumberPage.ClickSaveCloseButton();
            clientPhoneNumberPage.ClickSaveCloseButton();
            clientPhoneNumberPage.ClickSaveCloseButton();

            // Verify that Activities table is not showing any activity
            driver = driver.SwitchTo().Window(HomeWindow);
            homePage.ClickClientXRibbonTab(clientName);
            clientPage = new ClientPage(driver);
            clientPage.ClickPageTitle();

            Table table = new Table(UICommon.GetSearchResultTable(driver));

            Assert.IsTrue(table.GetNoRecordsInTable(), "Client Phone Number Updation Activity Getting displayed !!!!!");

            // Update the Personal Mobile, Personal Preferred Contact Number, Work Preferred Contact Number and Fax and save the record
            clientPage.SetMobileNumber(MobileNumber);
            clientPage.SetPersonalPreferredMobileNumber(FixedLineNumber);
            clientPage.SetWorkPreferredNumber(PagerNumber);
            clientPage.SetFaxNumber(FaxNumber);

            clientPage.ClickSaveCloseButton();

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

            clientPage = new ClientPage(driver);
            clientPage.ClickPageTitle();
            Thread.Sleep(500);
            table = new Table(clientPage.GetActivitiesTable());
            Assert.IsTrue(table.MatchingCellFound("Subject", "Client Profile Phone Number updated"), "Client Phone Number Updation Activity NOT displayed !!!!!");
            StringAssert.Contains(table.GetCellValue("Subject", "Client Profile Phone Number updated", "Actual End"), DateTime.Now.ToString("dd/MM/yyyy"));
        }
        public void ATC4440_CRMClientPhoneDelete()
        {
            //Login as CRM default user.
            User user = this.environment.GetUser(SecurityRole.GeneralStaff);
            new LoginDialog().Login(user.Id, user.Password);
            /*
            Person Client is needed with following fields populated:
            - Personal Mobile
            - Personal Preferred Contact Number
            - Work Preferred Contact Number
            - Fax*/
            string clientName = "CLIENT PHONEDEL" + UICommon.GetRandomString(3);

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

            ClientsSearchPage clientsSearchPage = new ClientsSearchPage(driver);
            clientsSearchPage.ClickNewClientButton();
            ClientPage clientPage = new ClientPage(driver);
            clientPage.ClickPageTitle();
            Thread.Sleep(1000);

            clientPage.SetFamilyName(clientName);
            clientPage.ClickSaveButton();

            //Navigate to client phone numbers
            driver = driver.SwitchTo().Window(HomeWindow);
            homePage.HoverClientXRibbonTab(clientName);
            homePage.ClickClientXPhoneNumbersRibbonButton();

            //Add new phone numbers
            clientPage = new ClientPage(driver);
            string BaseWindow = driver.CurrentWindowHandle;
            clientPage.ClickAddNewClientPhoneImage();

            //Enter payment reference details
            driver = UICommon.SwitchToNewBrowserWithTitle(driver, BaseWindow, "Client Phone Number");

            //Assert availability list
            ClientPhoneNumberPage clientPhoneNumberPage = new ClientPhoneNumberPage(driver);

            //Create Fixed Line Number
            clientPhoneNumberPage.SetTypeListValue("Fixed Line");
            clientPhoneNumberPage.SetAreaCodeValue("07");
            clientPhoneNumberPage.SetPhoneNumberValue("11111111");
            clientPhoneNumberPage.ClickSaveButton();
            //Assert new phone number has saved
            string FixedLineNumber = clientPhoneNumberPage.GetPhoneNumber();

            clientPhoneNumberPage.ClickNewButton();
            clientPhoneNumberPage.ClickPageTitle();
            clientPhoneNumberPage.SetClientNameList(clientName);
            clientPhoneNumberPage.SetTypeListValue("Mobile");
            clientPhoneNumberPage.SetPhoneNumberValue("0422222222");
            clientPhoneNumberPage.ClickSaveButton();
            //Assert new phone number has saved
            string MobileNumber = clientPhoneNumberPage.GetPhoneNumber();

            clientPhoneNumberPage.ClickNewButton();
            clientPhoneNumberPage.ClickPageTitle();
            clientPhoneNumberPage.SetClientNameList(clientName);
            clientPhoneNumberPage.SetTypeListValue("Fax");
            clientPhoneNumberPage.SetAreaCodeValue("07");
            clientPhoneNumberPage.SetPhoneNumberValue("33333333");
            clientPhoneNumberPage.ClickSaveButton();
            //Assert new phone number has saved
            string FaxNumber = clientPhoneNumberPage.GetPhoneNumber();

            clientPhoneNumberPage.ClickNewButton();
            clientPhoneNumberPage.ClickPageTitle();
            clientPhoneNumberPage.SetClientNameList(clientName);
            clientPhoneNumberPage.SetTypeListValue("Pager");
            clientPhoneNumberPage.SetAreaCodeValue("07");
            clientPhoneNumberPage.SetPhoneNumberValue("44444444");
            clientPhoneNumberPage.ClickSaveButton();
            //Assert new phone number has saved
            string PagerNumber = clientPhoneNumberPage.GetPhoneNumber();

            clientPhoneNumberPage.ClickSaveCloseButton();
            clientPhoneNumberPage.ClickSaveCloseButton();
            clientPhoneNumberPage.ClickSaveCloseButton();
            clientPhoneNumberPage.ClickSaveCloseButton();

            // Verify that Activities table is not showing any activity
            driver = driver.SwitchTo().Window(HomeWindow);
            homePage.ClickClientXRibbonTab(clientName);
            clientPage = new ClientPage(driver);
            clientPage.ClickPageTitle();

            Table table = new Table(UICommon.GetSearchResultTable(driver));

            Assert.IsTrue(table.GetNoRecordsInTable(), "Client Phone Number Updation Activity Getting displayed !!!!!");

            // Update the Personal Mobile, Personal Preferred Contact Number, Work Preferred Contact Number and Fax and save the record
            clientPage.SetMobileNumber(MobileNumber);
            clientPage.SetPersonalPreferredMobileNumber(FixedLineNumber);
            clientPage.SetWorkPreferredNumber(PagerNumber);
            clientPage.SetFaxNumber(FaxNumber);

            clientPage.ClickSaveButton();
            string clientId = clientPage.GetClientID();

            clientPage.ClickSaveCloseButton();

            //Clients Services > Clients Double click on the prepared record
            clientsSearchPage = new ClientsSearchPage(driver);
            clientsSearchPage.SetClientSearchText(clientId);
            table = new Table(clientsSearchPage.GetSearchResultTable());
            table.ClickCellValue("RTA Client Id", clientId, "Full Name");

            clientPage = new ClientPage(driver);
            clientPage.ClickPageTitle();
            Thread.Sleep(500);
            string date = DateTime.Today.ToString("d/MM/yyyy");
            string time = DateTime.Now.ToString("h:mm tt");
            /*Clear the following fields and save record:
            - Personal Mobile
            - Personal Preferred Contact Number
            - Work Preferred Contact Number
            - Fax*/

            clientPage.ClearMobileNumber();
            clientPage.ClickPageTitle();
            clientPage.ClearPersonalPreferredMobileNumber();
            clientPage.ClickPageTitle();
            clientPage.ClearWorkPreferredNumber();
            clientPage.ClickPageTitle();
            clientPage.ClearFaxNumber();

            clientPage.ClickSaveCloseButton();

            clientsSearchPage = new ClientsSearchPage(driver);
            clientsSearchPage.SetClientSearchText(clientId);
            table = new Table(clientsSearchPage.GetSearchResultTable());
            table.ClickCellValue("RTA Client Id", clientId, "Full Name");
            clientPage = new ClientPage(driver);
            clientPage.ClickPageTitle();

            //Inspect resultant entry in Activity sub grid.
            Table headerTable = new Table(clientPage.GetActivitiesHeaderTable());
            headerTable.ClickTableColumnHeader("Actual End");
            Thread.Sleep(2000);

            Table activitiesTable = new Table(clientPage.GetActivitiesTable());
            Assert.IsTrue(activitiesTable.MatchingCellFound("Subject", "Client Profile Phone Number updated"), "Client Phone Number Updation Activity NOT displayed !!!!!");

            activitiesTable.ClickCellValue("Subject", "Client Profile Phone Number updated", "Subject");

            //Client Management Activity is created as a note to users that the phone numbers were changed (includes current value of each field and a note referring the user to audit history).
            ClientManagementActivityPage activityPage = new ClientManagementActivityPage(driver);
            activityPage.ClickPageTitle();
            StringAssert.Contains(activityPage.GetDescription(), "Personal Mobile:   [no value]");
            StringAssert.Contains(activityPage.GetDescription(), "Personal Preferred Contact Number:   [no value]");
            StringAssert.Contains(activityPage.GetDescription(),"Work Preferred Contact Number:   [no value]");
            StringAssert.Contains(activityPage.GetDescription(), "Fax:   [no value]");
            StringAssert.Contains(activityPage.GetDescription(), "Note: the current values are displayed above. Refer to Audit History against the Client record for more information.");

            homePage.HoverCRMRibbonTab();
            homePage.ClickClientServicesRibbonButton();
            homePage.HoverClientServicesRibbonTab();
            homePage.ClickClientsRibbonButton();

            clientsSearchPage = new ClientsSearchPage(driver);
            clientsSearchPage.SetPageFilterList("Active Clients");

            clientsSearchPage.SetClientSearchText(clientId);

            Table clientTable = new Table(clientsSearchPage.GetSearchResultTable());
            IWebElement clientCell = clientTable.GetCellElementContainsValue("RTA Client Id", clientId, "Full Name");
            UICommon.DoubleClickElement(clientCell, driver);

            Thread.Sleep(5000);
            clientPage = new ClientPage(driver, "Clients Quick");

            /*Select the [Audit History] option from the entity navigation menu in the global ribbon.
             *Inspect audit history relating to deletions made in this test*/

            homePage.HoverClientRibbonTab(clientName);
            homePage.ClickClientXAuditRibbonButton();

            clientPage = new ClientPage(driver, "Clients Quick");
            Thread.Sleep(2000);

            /*Audit history shows:
            - What was deleted
            - Who deleted it
            - When it was deleted
            - What previous value was*/
            Table auditTable = new Table(clientPage.GetAuditHistoryTable());

            StringAssert.Contains(auditTable.GetCellValue("Event", "Update", "Changed Field"), "Fax");
            StringAssert.Contains(auditTable.GetCellValue("Event", "Update", "Changed Field"), "Mobile");
            StringAssert.Contains(auditTable.GetCellValue("Event", "Update", "Changed Field"), "Personal Preferred Contact Number");
            StringAssert.Contains(auditTable.GetCellValue("Event", "Update", "Changed Field"), "Work Preferred Contact Number");

            StringAssert.Contains(auditTable.GetCellValue("Event", "Update", "Old Value"), "+61 7 3333 3333");
            StringAssert.Contains(auditTable.GetCellValue("Event", "Update", "Old Value"), "+61 422 222 222");
            StringAssert.Contains(auditTable.GetCellValue("Event", "Update", "Old Value"), "+61 7 3333 3333");
            StringAssert.Contains(auditTable.GetCellValue("Event", "Update", "Old Value"), "+61 7 1111 1111");
            StringAssert.Contains(auditTable.GetCellValue("Event", "Update", "Old Value"), "+61 7 4444 4444");

            Assert.AreEqual(String.Empty, auditTable.GetCellValue("Event", "Update", "New Value").Trim());
            Assert.AreEqual(user.Id.ToLower() + " user", auditTable.GetCellValue("Event", "Update", "Changed By").ToLower());
            Assert.AreEqual(date + " " + time, auditTable.GetCellValue("Event", "Update", "Changed Date"));
        }
        public void ATC4405_CRMBusinessHoursandAfterHoursphone()
        {
            #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);

            clientsSearchPage.SetClientSearchText(clientName);
            Table table = new Table(clientsSearchPage.GetSearchResultTable());

            StringAssert.Equals(table.GetCellValue("Full Name", clientName, "Full Name"), clientName);
            table.ClickCellValue("Full Name", clientName, "Full Name");

            //Navigate to client phone numbers
            homePage.HoverClientXRibbonTab(clientName);
            homePage.ClickClientXPhoneNumbersRibbonButton();

            //Add new phone numbers
            ClientPage clientPage = new ClientPage(driver);
            string BaseWindow = driver.CurrentWindowHandle;
            clientPage.ClickAddNewClientPhoneImage();

            //Enter payment reference details
            driver = UICommon.SwitchToNewBrowserWithTitle(driver, BaseWindow, "Client Phone Number");
            //Assert availability list
            ClientPhoneNumberPage clientPhoneNumberPage = new ClientPhoneNumberPage(driver);
            Assert.IsTrue(clientPhoneNumberPage.GetAvailabilityListItem("Business hours only"));
            Assert.IsTrue(clientPhoneNumberPage.GetAvailabilityListItem("After hours only"));
            Assert.IsTrue(clientPhoneNumberPage.GetAvailabilityListItem("Anytime"));

            //Create 3 new phone numbers
                //clientPhoneNumberPage.ClickTypeList();
                clientPhoneNumberPage.SetTypeListValue("Fixed Line");
                //clientPhoneNumberPage.ClickAreaCodeElement();
                clientPhoneNumberPage.SetAreaCodeValue("07");
                //clientPhoneNumberPage.ClickPhoneNumberElement();
                clientPhoneNumberPage.SetPhoneNumberValue("11111111");
                clientPhoneNumberPage.ClickSaveButton();
                //Assert new phone number has saved
                string phoneNumber = clientPhoneNumberPage.GetPhoneNumber();

                clientPhoneNumberPage.ClickNewButton();
                clientPhoneNumberPage.ClickPageTitle();
                clientPhoneNumberPage.SetClientNameList(clientName);
                //clientPhoneNumberPage.SetClientNameListValue("BLAIR TEST");
                //clientPhoneNumberPage.ClickTypeList();
                clientPhoneNumberPage.SetTypeListValue("Mobile");
                //clientPhoneNumberPage.ClickPhoneNumberElement();
                clientPhoneNumberPage.SetPhoneNumberValue("0422222222");
                clientPhoneNumberPage.ClickSaveButton();
                //Assert new phone number has saved
                string phoneNumber2 = clientPhoneNumberPage.GetPhoneNumber();

                clientPhoneNumberPage.ClickNewButton();
                clientPhoneNumberPage.ClickPageTitle();
                clientPhoneNumberPage.SetClientNameList(clientName);
                //clientPhoneNumberPage.SetClientNameListValue("BLAIR TEST");
                //clientPhoneNumberPage.ClickTypeList();
                clientPhoneNumberPage.SetTypeListValue("Fax");
                //clientPhoneNumberPage.ClickAreaCodeElement();
                clientPhoneNumberPage.SetAreaCodeValue("07");
                //clientPhoneNumberPage.ClickPhoneNumberElement();
                clientPhoneNumberPage.SetPhoneNumberValue("33333333");
                clientPhoneNumberPage.ClickSaveButton();
                //Assert new phone number has saved
                string phoneNumber3 = clientPhoneNumberPage.GetPhoneNumber();

            clientPhoneNumberPage.ClickSaveCloseButton();
            clientPhoneNumberPage.ClickSaveCloseButton();
            clientPhoneNumberPage.ClickSaveCloseButton();

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

            clientPage.SetClientSearchText(clientName);
            table = new Table(clientPage.GetSearchResultTable());

            StringAssert.Equals(table.GetCellValue("Client", clientName, "Full Phone Number"), phoneNumber);

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