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 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 ATC3347_CRMEntityCreateNewClientPersonalMobileTest()
        {
            #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.Investigations);
            new LoginDialog().Login(user.Id, user.Password);

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

            //Search for already existing client
            ClientsSearchPage clientsSearchPage = new ClientsSearchPage(driver);
            Trace.Listeners.Add(new TextWriterTraceListener("TextWriterOutput.log", "myListener"));
            Trace.TraceInformation("Search for client start:" + DateTime.Now.ToString("ddMMyyyyhhmmssffff"));
            Trace.Flush();
            clientsSearchPage.SetClientSearchText(clientName);

            Table table = new Table(clientsSearchPage.GetSearchResultTable());
            StringAssert.Equals(table.GetCellValue("Full Name", clientName, "Full Name"), clientName);

            Trace.Listeners.Add(new TextWriterTraceListener("TextWriterOutput.log", "myListener"));
            Trace.TraceInformation("Search for client end:" + DateTime.Now.ToString("ddMMyyyyhhmmssffff"));
            Trace.Flush();

            table.ClickCellValue("Full Name", clientName, "Full Name");

            ClientPage clientPage = new ClientPage(driver);
            String BaseWindow = driver.CurrentWindowHandle;

            // Provide new Personal preferred Mobile number
            clientPage.ClickAddNewPersonalPreferredClientNumber();

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

            ClientPhoneNumberPage clientPhoneNumberPage = new ClientPhoneNumberPage(driver);
            //clientPhoneNumberPage.ClickTypeList();
            clientPhoneNumberPage.SetTypeListValue("Mobile");
            //clientPhoneNumberPage.ClickPhoneNumberElement();
            clientPhoneNumberPage.SetPhoneNumberValue("0422 222 222");
            clientPhoneNumberPage.ClickSaveCloseButton();

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

            // On Clients page verify that Personal preferred mobile number is correctly populated
            StringAssert.Equals(clientPage.GetPersonalPreferredMobileNumber(), "+61 422 222 222");

            #region Shut down Excel
            MyBook.Save();
            MyBook.Close();
            MyApp.Quit();
            #endregion
        }
        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
        }