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

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

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

            ClientsSearchPage clientsSearchPage = new ClientsSearchPage(driver);
            clientsSearchPage.ClickNewClientButton();
            ClientPage clientPage = new ClientPage(driver);
            clientPage.ClickPageTitle();
            clientPage.SetUnknownClientListValues("Yes");
            clientPage.SetGivenName("Given Name");
            clientPage.SetMiddleName("Middle Name");
            clientPage.ClickSaveButton();
            string ClientID = clientPage.GetClientID();
            clientPage.ClickSaveCloseButton();

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

            // Select VIEW: Active Clients - UNKNOWN-
            clientsSearchPage = new ClientsSearchPage(driver);
            clientsSearchPage.SetPageFilterList("Active Clients -UNKNOWN-");

            Table table = new Table(clientsSearchPage.GetHeaderSearchResultTable());
            table.ClickTableColumnHeader("RTA Client Id");
            table.ClickTableColumnHeader("RTA Client Id");

            // allow the client record to be created for the first name and populate the client surname with a standard token that is easy to identify and search on
            table = new Table(clientsSearchPage.GetSearchResultTable());
            StringAssert.Contains(table.GetCellValue("RTA Client Id", ClientID, "Full Name"), "GIVEN NAME MIDDLE NAME -UNKNOWN-");
            table.ClickCellValue("RTA Client Id", ClientID, "Full Name");

            clientPage = new ClientPage(driver);
            //  allow Investigation User to update the client surname.
            clientPage.ClickPageTitle();
            clientPage.SetUnknownClientListValues("No");
            clientPage.SetFamilyName("Family Name");
            clientPage.ClickSaveCloseButton();

            Trace.Listeners.Add(new TextWriterTraceListener("TextWriterOutput.log", "myListener"));
            Trace.TraceInformation("Search by Client ID start:" + DateTime.Now.ToString("ddMMyyyyhhmmssffff"));
            Trace.Flush();

            clientsSearchPage = new ClientsSearchPage(driver);
            clientsSearchPage.SetPageFilterList("Active Clients");
            clientsSearchPage.SetClientSearchText(ClientID);
            table = new Table(clientsSearchPage.GetSearchResultTable());
            StringAssert.Contains(table.GetCellValue("RTA Client Id", ClientID, "Full Name"), "GIVEN NAME MIDDLE NAME FAMILY NAME");

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

            table.ClickCellValue("RTA Client Id", ClientID, "Full Name");
            clientPage = new ClientPage(driver);
            clientPage.ClickPageTitle();
            clientPage.SetUnknownClientListValues("Yes");
            clientPage.ClickSaveCloseButton();

            driver.Quit();
            driver = null;

            this.TestSetup();

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

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

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

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

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

            // Verify that Family name and Unknown Client Fields are locked
            Assert.IsTrue(clientPage.VerifyElementLocked("rta_unknownclient"),"Unknown Field is NOT locked !!!!!");
            Assert.IsTrue(clientPage.VerifyElementLocked("lastname"), "Lastename Field is NOT locked !!!!!");
        }
        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"));
        }