public void ATC3337_CRMEntityClientConfirmvalidationofABN()
        {
            //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);

            clientsSearchPage.ClickNewClientButton();

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

            clientPage.SetABNACNValue("124324542747");
            clientPage.GetABNACNErrorText();

            clientPage.SetABNACNValue("7898281890n");
            clientPage.GetABNACNErrorText();

            clientPage.SetABNACNValue("78982818908");
            clientPage.GetABNACNErrorTextNotExist();

            clientPage.SetABNACNValue("005249981");
            clientPage.GetABNACNErrorTextNotExist();

            clientPage.SetARBNValue("123456789");
            clientPage.GetARBNErrorText();

            clientPage.SetARBNValue("12345678n");
            clientPage.GetARBNErrorText();

            clientPage.SetARBNValue("005249981");
            clientPage.GetARBNErrorTextNotExist();
        }
        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 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 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 ATC4419_CRMEntityClientDOBFieldTest()
        {
            #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();

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

            // Add new client name
            ClientPage clientPage = new ClientPage(driver);
            string BaseWindow = driver.CurrentWindowHandle;

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

            Assert.IsTrue(clientPage.CheckFamilyNameErrorPresent(), "Error in saving Family Name");

            // Set {Date of Birth} field to tomorrow.
            clientPage.SetDateOfBirthValue(DateTime.Now.AddDays(1).ToString("dd/MM/yyyy"));
            clientPage.ClickSaveButton();
            StringAssert.Contains(clientPage.GetBirthdayErrorText(), "Invalid Date of Birth entered, please correct.");

            // Set {Date of Birth} field to make client less than 16 years old.
            clientPage.SetDateOfBirthValue(DateTime.Now.AddYears(-5).ToString("dd/MM/yyyy"));
            clientPage.ClickSaveButton();
            StringAssert.Contains(clientPage.GetBirthdayErrorText(), "Invalid Date of Birth entered, please correct.");

            // Set {Date of Birth} field to make client have year of birth prior to 1900 (e.g. 1899).
            clientPage.SetDateOfBirthValue("01/01/1899");
            clientPage.ClickSaveButton();
            StringAssert.Contains(clientPage.GetBirthdayErrorText(), "The specified date format is invalid or the date is out of valid range. Enter a valid date in the format: d/MM/yyyy");

            // Set {Date of Birth} field to make client 16 years old.
            driver.Navigate().Refresh();
            clientPage = new ClientPage(driver);
            clientPage.SetDateOfBirthValue(DateTime.Now.AddYears(-16).ToString("dd/MM/yyyy"));
            clientPage.ClickSaveButton();
            Assert.IsFalse(clientPage.CheckDateOfBirthErrorPresent(), "Error in saving date of birth field to make client 16 years old.");

            // Update {Date of Birth} field to tomorrow.
            clientPage.SetDateOfBirthValue(DateTime.Now.AddDays(1).ToString("dd/MM/yyyy"));
            clientPage.ClickSaveButton();
            StringAssert.Contains(clientPage.GetBirthdayErrorText(), "Invalid Date of Birth entered, please correct.");

            // Update {Date of Birth} field to make client less than 16 years old.
            clientPage.SetDateOfBirthValue(DateTime.Now.AddYears(-6).ToString("dd/MM/yyyy"));
            clientPage.ClickSaveButton();
            StringAssert.Contains(clientPage.GetBirthdayErrorText(), "Invalid Date of Birth entered, please correct.");

            // Set {Date of Birth} field to make client have year of birth prior to 1900 (e.g. 1899).
            clientPage.SetDateOfBirthValue("01/01/1899");
            clientPage.ClickSaveButton();
            StringAssert.Contains(clientPage.GetBirthdayErrorText(), "The specified date format is invalid or the date is out of valid range. Enter a valid date in the format: d/MM/yyyy");

            // Remove error message
            clientPage.SetDateOfBirthValue("");
            clientPage.ClickSaveButton();

            // Update {Date of Birth} field to 01/01/1900
            driver.Navigate().Refresh();
            clientPage = new ClientPage(driver);
            clientPage.SetDateOfBirthValue("01/01/1900");
            clientPage.ClickSaveButton();
            Assert.IsFalse(clientPage.CheckDateOfBirthErrorPresent(), "Error in saving date of birth field to 01/01/1900");

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

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

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

            // Fill in mandatory fields
            clientPage.SetClientType("Organisation");
            clientPage.SetOrganizationName("TC Investigation");
            clientPage.ClickSaveButton();
            clientPage.ClickPageTitle();

            string clientID = clientPage.GetClientID();

            // Verify that "Physical Address is blank, please select an address." error message is displayed
            Assert.IsTrue(clientPage.VerifyWarningMessagePresent("rta_physicaladdressid"), "Physical Address blank message NOT displayed");
            StringAssert.Contains(clientPage.GetWarningMessage("rta_physicaladdressid"), "Physical Address is blank, please select an address.");

            // Enter valid Physical address
            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"));
            Assert.IsFalse(clientPage.VerifyWarningMessagePresent("rta_physicaladdressid"), "Physical Address blank message DISPLAYED!!!!!");
        }
        public void ATC3312_CRMInvestigationCaseCloseAndReopen()
        {
            //There is only 1
            string InvestigationWindowHandle; // for driver
            string ClientWindowHandle; // for ClientDriver

            string ClientName = "CLIENT CASE" + UICommon.GetRandomString(3);

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

            // Create Investigation Case
            HomePage homePageInvestigation = new HomePage(driver);
            InvestigationWindowHandle = driver.CurrentWindowHandle;
            homePageInvestigation.HoverCRMRibbonTab();
            homePageInvestigation.ClickInvestigationsRibbonButton();
            homePageInvestigation.HoverInvestigationsRibbonTab();
            homePageInvestigation.ClickInvestigationsCasesRibbonButton();

            // Verify that Investigation Officer is able to record Phone call for Investigation Case
            InvestigationCaseSearchPage investigationsCaseSearchPage = new InvestigationCaseSearchPage(driver);
            investigationsCaseSearchPage.ClickNewInvestigationCaseButton();

            // Create new Investigation case
            InvestigationCasePage investigationCasePage = new InvestigationCasePage(driver);
            investigationCasePage.ClickSaveButton();
            String investigationID = investigationCasePage.GetInvestigationCaseNumber();

            IWebDriver ClientDriver = null;
            // Spawn a new window and open a Client record
            if (Properties.Settings.Default.BROWSER == BrowserType.Ie)
            {
                ClientDriver = new BrowserContext().WebDriver;
                this.environment = TestEnvironment.GetTestEnvironment();
            }

            ClientDriver.Navigate().GoToUrl(this.environment.Url);
            new LoginDialog().Login(user.Id, user.Password);

            // Create new Client Profile
            HomePage homePageClient = new HomePage(ClientDriver);
            ClientWindowHandle = ClientDriver.CurrentWindowHandle;
            homePageClient.HoverCRMRibbonTab();
            homePageClient.ClickClientServicesRibbonButton();
            homePageClient.HoverClientServicesRibbonTab();
            homePageClient.ClickClientsRibbonButton();

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

            ClientPage clientPage = new ClientPage(ClientDriver);
            clientPage.ClickPageTitle();
            clientPage.PopulateNewClient(ClientName);
            clientPage.ClickSaveCloseButton();
            Thread.Sleep(3000);
            clientsSearchPage = new ClientsSearchPage(ClientDriver);

            // ADD the Client from the second open window as a Case Party to the Investigation Case
            driver.SwitchTo().Window(InvestigationWindowHandle);
            investigationCasePage = new InvestigationCasePage(driver);
            investigationCasePage.ClickPageTitle();
            investigationCasePage.ClickAddCasePartyRecordButton();

            investigationCasePage.SwitchNewBrowserWithTitle(driver, InvestigationWindowHandle, "Case Party");

            CasePartyPage casePartyPage = new CasePartyPage(driver);
            casePartyPage.ClickPageTitle();
            casePartyPage.SetClientName(ClientName);
            casePartyPage.ClickSaveCloseButton();
            Thread.Sleep(3000);

            driver = driver.SwitchTo().Window(InvestigationWindowHandle);
            investigationCasePage.ClickSaveCloseButton();

            // Verify new Case Management Activity is shown in the Investigation Case which documents that the Case Party was added and by whom.
            investigationsCaseSearchPage = new InvestigationCaseSearchPage(driver);
            investigationsCaseSearchPage.SetSearchRecord(investigationID);
            Table table = new Table(investigationsCaseSearchPage.GetSearchResultTable());
            table.ClickCellValue("Case Number", investigationID, "Case Number");

            investigationCasePage = new InvestigationCasePage(driver);
            investigationCasePage.ClickPageTitle();
            table = new Table(investigationCasePage.GetActivitiesSearchResultTable());
            StringAssert.Contains(table.GetCellContainsValue("Subject", "Case party " + ClientName + " added to case " + investigationID, "Activity Status"), "Completed");
            StringAssert.Contains(table.GetCellContainsValue("Subject", "Case party " + ClientName + " added to case " + investigationID, "Modified By"), "SRCRM5-TEAdmin Last Name");

            //Client window
            ClientDriver = ClientDriver.SwitchTo().Window(ClientWindowHandle);
            clientsSearchPage = new ClientsSearchPage(ClientDriver);
            clientsSearchPage.SetClientSearchText(ClientName);

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

            clientPage = new ClientPage(ClientDriver);
            clientPage.ClickSeeRecordsAssociatedWithThisViewButton("Activities");

            clientPage.SwitchToFrame();

            clientPage.SetPageFilterList("All Activities", ClientDriver);
            clientPage.SetFilterOnList("All", ClientDriver);
            table = new Table(clientPage.GetActivitiesAssociatedViewTable(ClientDriver));
            StringAssert.Contains(table.GetCellValue("Subject", "Case party " + ClientName + " added to case " + investigationID, "Activity Status"), "Completed");
            StringAssert.Contains(table.GetCellValue("Subject", "Case party " + ClientName + " added to case " + investigationID, "Modified By"), "SRCRM5-TEAdmin Last Name");

            // Investigation Case window, SELECT Start Dialog and close the Investigation case
            driver.SwitchTo().Window(InvestigationWindowHandle);
            investigationCasePage = new InvestigationCasePage(driver);
            investigationCasePage.ClickPageTitle();
            investigationCasePage.ClickStartDialogButton();

            table = new Table(investigationCasePage.GetProcessSearchResultTable());
            table.ClickCell("Process Name", "INV: Close investigation case", "Created On");
            investigationCasePage.ClickDialogAddButton();

            driver = UICommon.SwitchToNewBrowserWithTitle(driver, InvestigationWindowHandle, "INV:");

            INVPage iNVPage = new INVPage(driver);
            iNVPage.ClickNextButton();
            iNVPage.ClickNextButton();
            iNVPage.ClickNextButton();
            iNVPage.ClickFinishButton();
            Thread.Sleep(3000);

            driver = driver.SwitchTo().Window(InvestigationWindowHandle);
            investigationCasePage = new InvestigationCasePage(driver);
            investigationCasePage.ClickSaveCloseButton();

            // Investigation Case is shown as Inactive. A new Case Management Activity is shown in the Investigation Case which documents that the case was closed and by whom.
            investigationsCaseSearchPage = new InvestigationCaseSearchPage(driver);
            investigationsCaseSearchPage.SetPageFilterList("All Investigation Cases");

            table = new Table(investigationsCaseSearchPage.GetHeaderSearchResultTable());
            table.ClickTableColumnHeader("Case Number");

            table = new Table(investigationsCaseSearchPage.GetSearchResultTable());
            table.ClickCellValue("Case Number", investigationID, "Case Number");

            investigationCasePage = new InvestigationCasePage(driver);
            investigationCasePage.ClickPageTitle();
            StringAssert.Contains(investigationCasePage.GetStatus(), "Closed");
            table = new Table(investigationCasePage.GetActivitiesSearchResultTable());
            StringAssert.Contains(table.GetCellContainsValue("Subject", investigationID + " case closed: Act applies-Insufficient evidence", "Activity Status"), "Completed");
            StringAssert.Contains(table.GetCellContainsValue("Subject", investigationID + " case closed: Act applies-Insufficient evidence", "Modified By"), "IMSTestU03");

            // A new Case Management Activity is shown in the Client which documents that the case was closed and by whom.
            ClientDriver.SwitchTo().Window(ClientWindowHandle);
            homePageClient.HoverCRMRibbonTab();
            homePageClient.ClickClientServicesRibbonButton();
            homePageClient.HoverClientServicesRibbonTab();
            homePageClient.ClickClientsRibbonButton();

            clientsSearchPage = new ClientsSearchPage(ClientDriver);
            clientsSearchPage.SetClientSearchText(ClientName);

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

            clientPage = new ClientPage(ClientDriver);
            clientPage.ClickSeeRecordsAssociatedWithThisViewButton("Activities");

            clientPage.SwitchToFrame();

            Thread.Sleep(1000);
            clientPage.SetPageFilterList("All Activities", ClientDriver);
            clientPage.SetFilterOnList("All", ClientDriver);
            table = new Table(clientPage.GetActivitiesAssociatedViewTable(ClientDriver));
            Console.WriteLine(table.GetRowCount());
            StringAssert.Contains(table.GetCellValue("Subject", investigationID + " case closed: Act applies-Insufficient evidence", "Activity Status"), "Completed");
            StringAssert.Contains(table.GetCellValue("Subject", investigationID + " case closed: Act applies-Insufficient evidence", "Modified By"), "IMSTestU03");

            // In the Investigation Case, SELECT Start Dialog and Re-Open the case
            driver.SwitchTo().Window(InvestigationWindowHandle);
            investigationCasePage = new InvestigationCasePage(driver);
            investigationCasePage.ClickPageTitle();
            investigationCasePage.ClickStartDialogButton();

            table = new Table(investigationCasePage.GetProcessSearchResultTable());
            table.ClickCell("Process Name", "INV: Re-open investigation case", "Created On");
            investigationCasePage.ClickDialogAddButton();

            driver = UICommon.SwitchToNewBrowserWithTitle(driver, InvestigationWindowHandle, "INV:");

            iNVPage = new INVPage(driver);
            iNVPage.ClickNextButton();
            iNVPage.ClickNextButton();
            iNVPage.ClickFinishButton();

            driver = driver.SwitchTo().Window(InvestigationWindowHandle);
            investigationCasePage = new InvestigationCasePage(driver);
            homePageInvestigation.HoverInvestigationsRibbonTab();
            homePageInvestigation.ClickInvestigationsCasesRibbonButton();
            investigationsCaseSearchPage = new InvestigationCaseSearchPage(driver);
            investigationsCaseSearchPage.SetSearchRecord(investigationID);

            table = new Table(investigationsCaseSearchPage.GetSearchResultTable());
            table.ClickCellValue("Case Number", investigationID, "Case Number");

            // Investigation Case is shown as Active. A new Case Management Activity is shown in the Investigation Case which documents that the case was closed and by whom.
            investigationCasePage = new InvestigationCasePage(driver);
            investigationCasePage.ClickPageTitle();
            StringAssert.Contains(investigationCasePage.GetStatus(), "Case finalisation");
            table = new Table(investigationCasePage.GetActivitiesSearchResultTable());
            StringAssert.Contains(table.GetCellContainsValue("Subject", investigationID + " case re-opened: Case finalisation - Case closed discussion", "Activity Status"), "Completed");
            StringAssert.Contains(table.GetCellContainsValue("Subject", investigationID + " case re-opened: Case finalisation - Case closed discussion", "Modified By"), "IMSTestU03");

            // A new Case Management Activity is shown in the Client which documents that the case was reopened and by whom.
            ClientDriver.SwitchTo().Window(ClientWindowHandle);
            homePageClient.HoverClientServicesRibbonTab();
            homePageClient.ClickClientsRibbonButton();
            clientsSearchPage = new ClientsSearchPage(ClientDriver);
            clientsSearchPage.SetClientSearchText(ClientName);

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

            clientPage = new ClientPage(ClientDriver);
            clientPage.ClickSeeRecordsAssociatedWithThisViewButton("Activities");

            clientPage.SwitchToFrame();
            Thread.Sleep(1000);
            clientPage.SetPageFilterList("All Activities", ClientDriver);
            clientPage.SetFilterOnList("All", ClientDriver);
            table = new Table(clientPage.GetActivitiesAssociatedViewTable(ClientDriver));
            StringAssert.Contains(table.GetCellValue("Subject", investigationID + " case re-opened: Case finalisation - Case closed discussion", "Activity Status"), "Completed");
            StringAssert.Contains(table.GetCellValue("Subject", investigationID + " case re-opened: Case finalisation - Case closed discussion", "Modified By"), "IMSTestU03");
        }
        public void ATC3339_CRMEntityClientEmailshouldnotbeautocapitalised()
        {
            //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);

            clientsSearchPage.ClickNewClientButton();

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

            clientPage.setEmail1Address("*****@*****.**");
            clientPage.GetEmailAddress1ErrorTextNotExist();
            Assert.AreEqual(clientPage.GetBannerEmailValue(), "*****@*****.**", true, "Email comparison failed");

            clientPage.setEmail1Address("*****@*****.**");
            clientPage.GetEmailAddress1ErrorTextNotExist();
            Assert.AreEqual(clientPage.GetBannerEmailValue(), "*****@*****.**", true, "Email comparison failed");

            clientPage.setEmail1Address("test@TESTCOM");
            StringAssert.Contains(clientPage.GetEmail1ErrorText(), "Invalid text entered for Email 1");
            clientPage.setEmail1Address("*****@*****.**");
            clientPage.GetEmailAddress1ErrorTextNotExist();

            clientPage.setEmail1Address("[email protected]");
            StringAssert.Contains(clientPage.GetEmail1ErrorText(), "Invalid text entered for Email 1");
            clientPage.setEmail1Address("*****@*****.**");
            clientPage.GetEmailAddress1ErrorTextNotExist();

            clientPage.setEmail1Address("[email protected]");
            StringAssert.Contains(clientPage.GetEmail1ErrorText(), "Invalid text entered for Email 1");
            clientPage.setEmail1Address("*****@*****.**");
            clientPage.GetEmailAddress1ErrorTextNotExist();
        }
        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 ATC4444_CRMClientEmailDelete()
        {
            //Login as CRM default user.
            User user = this.environment.GetUser(SecurityRole.GeneralStaff);
            new LoginDialog().Login(user.Id, user.Password);

            /*Data preparation step
            Organisation Client is needed with following fields populated:
            - Email 1
            - Email 2*/

            string clientName = "CLIENTEMAILDEL" + 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.SetClientType("Organisation");
            clientPage.SetOrganizationName(clientName);
            clientPage.ClickSaveButton();

            string email1 = clientName + "*****@*****.**";
            string email2 = clientName + "*****@*****.**";

            clientPage.SetEmail1ID(clientName + "*****@*****.**");
            clientPage.SetEmail2ID(clientName + "*****@*****.**");

            clientPage.ClickSaveButton();

            Assert.AreEqual(email1, clientPage.GetEmail1ID(),"Validate the email id1 is set correctly");
            Assert.AreEqual(email2, clientPage.GetEmail2ID(),"Validate the email id2 is set correctly");

            string clientID = clientPage.GetClientID();
            clientPage.ClickSaveCloseButton();

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

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

            //Clear the following fields and save record:- Email 1- Email 2
            clientPage = new ClientPage(driver);
            clientPage.ClearEmail1Id();
            clientPage.ClearEmail2Id();
            string date = DateTime.Today.ToString("d/MM/yyyy");
            string time = DateTime.Now.ToString("h:mm tt");

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

            clientTable = new Table(clientsSearchPage.GetSearchResultTable());
            clientTable.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());

            //Client Management Activity is created as a note to users that the email address fields were changed (includes current value of each field and a note referring the user to audit history).
            Assert.IsTrue(activitiesTable.MatchingCellFound("Subject", "Client E-mail Address updated"), "Client Management Activity for Email field updation Created!!!");
            activitiesTable.ClickCellValue("Subject", "Client E-mail Address updated", "Subject");

            ClientManagementActivityPage activityPage = new ClientManagementActivityPage(driver);
            activityPage.ClickPageTitle();
            StringAssert.Contains(activityPage.GetDescription(), "Email Address (primary):   [no value]");
            StringAssert.Contains(activityPage.GetDescription(), "Email Address (secondary):   [no value]");
            StringAssert.Contains(activityPage.GetDescription(), "Note: the current values are displayed above. Refer to Audit History against the Client record for more information.");

            //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.HoverClientServicesRibbonTab();
            homePage.ClickClientsRibbonButton();

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

            clientTable = new Table(clientsSearchPage.GetSearchResultTable());

            clientTable.ClickCellValue("RTA Client Id", clientID, "Full Name");

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

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

            clientPage = new ClientPage(driver);
            Thread.Sleep(2000);

            /*Audit history shows:
            - What was deleted
            - Who deleted it
            - When it was deleted
            - What previous value was*/
            clientPage = new ClientPage(driver);
            Table auditTable = new Table(clientPage.GetAuditHistoryTable());
            StringAssert.Contains(auditTable.GetCellValue("Event", "Update", "Changed Field"), "Email Address (primary)");
            StringAssert.Contains(auditTable.GetCellValue("Event", "Update", "Changed Field"), "Email Address (secondary)");

            Assert.AreEqual(email1+System.Environment.NewLine+email2, auditTable.GetCellValue("Event", "Update", "Old Value"));
            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 ATC4439_ClientAlertsValidation()
        {
            //Login in as role
            User user = this.environment.GetUser(SecurityRole.Investigations);
            new LoginDialog().Login(user.Id, user.Password);

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

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

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

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

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

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

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

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

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

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

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

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

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

            Assert.IsTrue(alertPage.VerifyOtherAlertMandatoryFieldIconPresent());

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

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

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

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

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

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

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

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

            Assert.IsTrue(alertPage.VerifyOtherAlertMandatoryFieldIconPresent());

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

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

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

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

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

            Assert.IsTrue(alertPage.VerifyOtherAlertMandatoryFieldIconPresent());

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

            alertPage.ClickSaveCloseIMG();

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

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

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

            Assert.IsTrue(alertPage.VerifyOtherAlertMandatoryFieldIconPresent());

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

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

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

            alertTable = new Table(clientPage.GetCurrentAlertsTable());
            Assert.IsTrue(alertTable.MatchingCellFound("Other Alert", "Other Alert Four"), "Validating the fourth alert displayed in the next page of alert table");
        }
        public void ATC4433_CommonTriggerPointCopyAddressFromParent()
        {
            //Login to CRM as General staff user.
            User user = this.environment.GetUser(SecurityRole.GeneralStaff);
            new LoginDialog().Login(user.Id, user.Password);

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

            //Create Parent Organization with Postal address
            ClientsSearchPage clientsSearchPage = new ClientsSearchPage(driver);
            clientsSearchPage.ClickNewClientButton();

            ClientPage clientPage = new ClientPage(driver);
            clientPage.ClickPageTitle();
            string parentOrganisation = "TCParentOrganization"+ UICommon.GetRandomString(5);

            clientPage.SetClientType("Organisation");
            clientPage.SetOrganizationName(parentOrganisation);
            clientPage.ClickSaveButton();

            string BaseWindow = driver.CurrentWindowHandle;
            clientPage.ClickCreateNewClientAddressButton("rta_postaladdressid");
            driver = UICommon.SwitchToNewBrowserWithTitle(driver, BaseWindow, "Client Address");
            ClientNewAddressPage clientNewAddressPage = new ClientNewAddressPage(driver);
            clientNewAddressPage.SetAddressDetails("Australian Physical", 10, "GRACELAND");

            driver = driver.SwitchTo().Window(BaseWindow);
            clientPage = new ClientPage(driver);
            Assert.AreEqual("10 GRACELAND", clientPage.GetAddressValue("rta_postaladdressid"));

            clientPage.ClickSaveCloseButton();

            //Create child with parent organization has postal address
            clientsSearchPage = new ClientsSearchPage(driver);
            clientsSearchPage.ClickNewClientButton();

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

            string childOrganisation = "TCChildOrganization"+ UICommon.GetRandomString(5);
            clientPage.SetClientType("Organisation");
            clientPage.SetOrganizationName(childOrganisation);
            clientPage.SetParentOrganization(parentOrganisation.ToUpper());
            clientPage.ClickSaveButton();
            string clientID = clientPage.GetClientID();

            //Select "Start Dialog" item from top entity menu.
            clientPage.ClickStartDialogButton();

            /*Run dialog "Copy an address from parent organisation":
             *For client where parent organisation has postal address but no physical address
             *Select YES for Postal address and YES for Physical addres
             */
            Table table = new Table(clientPage.GetProcessSearchResultTable());
            table.ClickCell("Process Name", "Copy an address from parent organisation", "Created On");

            BaseWindow = driver.CurrentWindowHandle;
            clientPage.ClickDialogAddButton();

            Thread.Sleep(2000);
            driver = UICommon.SwitchToNewBrowserWithTitle(driver, BaseWindow, "Copy an address");
            CopyAddressPage copyAddressPage = new CopyAddressPage(driver);

            copyAddressPage.SetCopyPhysicalAddressYes();
            copyAddressPage.SetCopyPostalAddressYes();

            //User is notified that no Physical address is copied.
            copyAddressPage.ClickNextButton();
            Assert.AreEqual(copyAddressPage.GetErrorMessage(), "The parent organisation does not have a physical address");

            /*For client where parent organisation has postal address but no physical address
             *Select NO for Postal address and YES for Physical address
             */
            copyAddressPage.ClickPreviousButton();
            copyAddressPage.SetCopyPostalAddressNo();
            copyAddressPage.SetCopyPhysicalAddressYes();
            copyAddressPage.ClickNextButton();
            ////User is notified that no Physical address is copied.
            Assert.AreEqual(copyAddressPage.GetErrorMessage(), "The parent organisation does not have a physical address");

            /* For client where parent organisation has postal address but no physical address
             * Select YES for Postal address and NO for Physical address
             */
            copyAddressPage.ClickPreviousButton();
            copyAddressPage.SetCopyPostalAddressYes();
            copyAddressPage.SetCopyPhysicalAddressNo();
            copyAddressPage.ClickNextButton();

            //Copy is successful.
            StringAssert.Contains(copyAddressPage.GetFinishMessage(), "This is the end of the dialog. Click Finish to close it");
            copyAddressPage.ClickFinishButton();

            driver = driver.SwitchTo().Window(BaseWindow);
            clientPage.ClickSaveCloseButton();
            Thread.Sleep(5000);
            clientsSearchPage = new ClientsSearchPage(driver);
            clientsSearchPage.SetClientSearchText(clientID);

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

            clientPage = new ClientPage(driver);
            Assert.AreEqual(clientPage.GetPostalAddress(), "10 GRACELAND");
        }
        public void ATC4430_CRMClientPhysicalAddressWarning()
        {
            //Login in as role
            User user = this.environment.GetUser(SecurityRole.SystemAdministrator);
            new LoginDialog().Login(user.Id, user.Password);

            //(Template) - Create new client (person) via Client Services group
            HomePage homePage = new HomePage(driver);
            homePage.HoverCRMRibbonTab();
            homePage.ClickClientServicesRibbonButton();
            homePage.HoverClientServicesRibbonTab();
            homePage.ClickClientsRibbonButton();

            ClientsSearchPage clientsSearchPage = new ClientsSearchPage(driver);

            clientsSearchPage.ClickNewClientButton();

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

            //Complete mandatory fields
            clientPage.SetClientType("Person");
            clientPage.SetFamilyName("TC PHYSICALADDRESSWARN");

            //Inspect screen for warning message regarding non-population of {Postal Address}.
            Assert.IsTrue(clientPage.VerifyWarningMessagePresent("rta_physicaladdressid"), "Physical Address blank message NOT displayed");
            StringAssert.Contains(clientPage.GetWarningMessage("rta_physicaladdressid"), "Physical Address is blank, please select an address.");

            //Attempt to save record with of {Physical Address} unpopulated. Record saves
            clientPage.ClickSaveButton();

            string clientID = clientPage.GetClientID();
            clientPage.ClickSaveCloseButton();

            //Reenter record.Warning message is redisplayed.
            clientsSearchPage = new ClientsSearchPage(driver);
            clientsSearchPage.SetClientSearchText(clientID);

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

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

            Assert.IsTrue(clientPage.VerifyWarningMessagePresent("rta_physicaladdressid"), "Physical Address blank message NOT displayed");
            StringAssert.Contains(clientPage.GetWarningMessage("rta_physicaladdressid"), "Physical Address is blank, please select an address.");
        }
        public void ATC4397_CRMCheckClientID()
        {
            //Login in as role
            User user = this.environment.GetUser(SecurityRole.Default);
            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.ClickNewClientButton();

            ClientPage clientPage = new ClientPage(driver);
            clientPage.ClickPageTitle();
            clientPage.PopulateNewClient("UPINA");
            clientPage.ClickSaveButton();
            string clientId1 = clientPage.GetClientID();
            int clientNum1 = int.Parse(clientId1.Substring(1));

            clientPage.ClickNewClientButton();

            clientPage = new ClientPage(driver);
            clientPage.ClickPageTitle();
            clientPage.PopulateNewClient("UPINAA");
            clientPage.ClickSaveButton();

            string clientId2 = clientPage.GetClientID();
            int clientNum2 = int.Parse(clientId2.Substring(1));

            if (clientId1.StartsWith("C") && (clientId2.StartsWith("C")))  //checks if clientID starts with "C"
            {
                Assert.AreEqual(clientNum1, clientNum2 - 1);      //if clientNum2 is a single increment from clientnum1 then TRUE
            }
            else
            {
                Assert.Fail();
            }
        }
        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 ATC4420_CRMInvestigationCreateNewClientViaInvestigationGroup()
        {
            //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.ClickClientsRibbonButton();

            ClientsSearchPage clientsSearchPage = new ClientsSearchPage(driver);
            string baseWindow = driver.CurrentWindowHandle;
            clientsSearchPage.ClickNewClientButton();

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

            // Fill in mandatory fields
            clientPage.SetClientType("Organisation");
            clientPage.SetOrganizationName("TC Investigation");
            clientPage.ClickSaveButton();

            string clientID = clientPage.GetClientID();

            clientPage.ClickSaveCloseButton();

            // Create another client
            driver = driver.SwitchTo().Window(baseWindow);

            clientsSearchPage.ClickNewClientButton();

            // Add second client
            clientPage = new ClientPage(driver);
            clientPage.ClickPageTitle();

            // Fill in mandatory fields
            clientPage.SetClientType("Organisation");
            clientPage.SetOrganizationName("TC Investigation second");
            clientPage.ClickSaveButton();

            string clientID2 = clientPage.GetClientID();

            StringAssert.Equals(clientID.Substring(0, 1), clientID2.Substring(0, 1));
            StringAssert.Equals(clientID.Substring(0, 1), "C"); //"Client ID is not starting with C"

            int clientNo1 = Convert.ToInt32(clientID.Substring(1));
            int clientNo2 = Convert.ToInt32(clientID2.Substring(1));

            Console.WriteLine(clientNo1);
            Console.WriteLine(clientNo2);

            if (clientNo2 - clientNo1 < 1)
            {
                throw new Exception("Client ID is not properly generated!!!");
            }
        }
        public void ATC6828_CRMUnknownClientfeatureEnabledforInvestigationsuser()
        {
            //Login in as role
            User user = this.environment.GetUser(SecurityRole.InvestigationsOfficer);
            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.ClickNewClientButton();

            ClientPage clientPage = new ClientPage(driver);
            clientPage.ClickPageTitle();
            StringAssert.Contains(clientPage.GetUnknownClientListValues(), "YesNo");
        }
        public void ATC3309_CRMInvestigationVerifyOfficerCanRecordPhoneCalls()
        {
            #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;

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

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

            // Verify that Investigation Officer is able to record Phone call for Investigation Case
            InvestigationCaseSearchPage investigationsCaseSearchPage = new InvestigationCaseSearchPage(driver);
            investigationsCaseSearchPage.ClickNewInvestigationCaseButton();

            // Create new case
            InvestigationCasePage investigationCasePage = new InvestigationCasePage(driver);
            string BaseWindow = driver.CurrentWindowHandle;
            investigationCasePage.ClickSaveButton();
            String investigationID = investigationCasePage.GetInvestigationCaseNumber();

            //Phone Call
            investigationCasePage.ClickPageTitle();
            investigationCasePage.ClickActivitiesAddButton();
            investigationCasePage.ClickAddActivity("Phone Call");
            driver = investigationCasePage.SwitchNewBrowserWithTitle(driver, BaseWindow, "Phone Call");

            PhoneCallPage phoneCall = new PhoneCallPage(driver);
            phoneCall.ClickPageTitle();
            phoneCall.SetSelectSubjectValue("Bond balance enquiry");
            phoneCall.SetSubject("Test 3309 Phone Call");
            phoneCall.SetRecipient(clientName);
            phoneCall.ClickSaveCloseButton();
            driver = driver.SwitchTo().Window(BaseWindow);
            investigationCasePage.CheckForErrors();
            investigationCasePage.ClickPageTitle();
            Table table = new Table(investigationCasePage.GetActivitiesSearchResultTable());
            StringAssert.Contains(table.GetCellContainsValue("Subject", "Test 3309 Phone Call", "Owner"), "IMSTestU03");

            table.ClickCellValue("Subject", "Test 3309 Phone Call", "Subject");
            phoneCall = new PhoneCallPage(driver);
            phoneCall.SwitchFrame();
            StringAssert.Contains(phoneCall.GetSelectSubjectValue(), "Bond balance enquiry");
            StringAssert.Contains(phoneCall.GetSubjectValue(), "Test 3309 Phone Call");
            StringAssert.Contains(phoneCall.GetRecipientValue(), clientName);
            StringAssert.Contains(phoneCall.GetSenderValue(), user.Id);

            // Verify that Investigation Officer is able to record Phone call for Client
            driver = driver.SwitchTo().Window(HomeWindow);
            homePage.HoverCRMRibbonTab();
            homePage.ClickClientServicesRibbonButton();
            homePage.HoverClientServicesRibbonTab();
            homePage.ClickClientsRibbonButton();

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

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

            clientPage.PopulateNewClient("Client Phone Record");
            clientPage.ClickSaveButton();

            clientPage.ClickActivitiesAddButton();
            clientPage.ClickAddActivity("Phone Call");
            Thread.Sleep(3000);
            driver = clientPage.SwitchNewBrowser(driver, BaseWindow, "Phone Call");

            phoneCall = new PhoneCallPage(driver);

            phoneCall.ClickPageTitle();
            phoneCall.SetSelectSubjectValue("Bond balance enquiry");
            phoneCall.SetSubject("Test 3309 Client Phone Call");

            phoneCall.SetRecipient(clientName);
            phoneCall.ClickSaveCloseButton();
            driver = driver.SwitchTo().Window(BaseWindow);
            phoneCall.CheckForErrors();
            clientPage.ClickPageTitle();
            table = new Table(clientPage.GetActivitiesTable());
            StringAssert.Contains(table.GetCellContainsValue("Subject", "Test 3309 Client Phone Call", "Owner"), "IMSTestU03");

            table.ClickCellValue("Subject", "Test 3309 Client Phone Call", "Subject");
            phoneCall = new PhoneCallPage(driver);
            StringAssert.Contains(phoneCall.GetSelectSubjectValue(), "Bond balance enquiry");
            StringAssert.Contains(phoneCall.GetSubjectValue(), "Test 3309 Client Phone Call");
            StringAssert.Contains(phoneCall.GetRecipientValue(), clientName);
            StringAssert.Contains(phoneCall.GetSenderValue(), user.Id);

            // Verify that Investigation Officer is able to record Phone call for General Case
            homePage.HoverCRMRibbonTab();
            homePage.ClickInvestigationsRibbonButton();
            homePage.HoverInvestigationsRibbonTab();
            homePage.ClickInvestigationsGeneralCasesRibbonButton();

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

            InvestigationGeneralCasePage investigationGeneralCasePage = new InvestigationGeneralCasePage(driver);
            BaseWindow = driver.CurrentWindowHandle;
            investigationGeneralCasePage.ClickPageTitle();
            investigationGeneralCasePage.SetTitle("New General Case");
            investigationGeneralCasePage.SetClientName(clientName);
            investigationGeneralCasePage.SetType("Complaint");
            investigationGeneralCasePage.ClickSaveButton();

            investigationGeneralCasePage.ClickActivitiesAddButton();
            investigationGeneralCasePage.ClickAddActivity("Phone Call");

            driver = investigationGeneralCasePage.SwitchNewBrowserWithTitle(driver, BaseWindow, "Phone Call");

            phoneCall = new PhoneCallPage(driver);

            phoneCall.ClickPageTitle();
            phoneCall.SetSelectSubjectValue("Bond balance enquiry");
            phoneCall.SetSubject("Test 3309 General Case Phone Call");

            phoneCall.SetRecipient(clientName);
            phoneCall.ClickSaveCloseButton();
            driver = driver.SwitchTo().Window(BaseWindow);
            phoneCall.CheckForErrors();
            investigationGeneralCasePage.ClickPageTitle();

             table = new Table(investigationGeneralCasePage.GetActivitiesTable());
            StringAssert.Contains(table.GetCellContainsValue("Subject", "Test 3309 General Case Phone Call", "Owner"), "IMSTestU03");

            table.ClickCellValue("Subject", "Test 3309 General Case Phone Call", "Subject");
            phoneCall = new PhoneCallPage(driver);
            StringAssert.Contains(phoneCall.GetSelectSubjectValue(), "Bond balance enquiry");
            StringAssert.Contains(phoneCall.GetSubjectValue(), "Test 3309 General Case Phone Call");
            StringAssert.Contains(phoneCall.GetRecipientValue(), clientName);
            StringAssert.Contains(phoneCall.GetSenderValue(), user.Id);

            #region Shut down Excel
            MyBook.Save();
            MyBook.Close();
            MyApp.Quit();
            #endregion
        }
        public void ATC3343_CRMAlterCloseReopenFrontCounterActivity()
        {
            #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.ToString();
            string FrontCounterActivity1 = "TC 3343 Front Counter Activity 1" + UICommon.GetRandomString(3);
            string FrontCounterActivity2 = "TC 3343 Front Counter Activity 2" + UICommon.GetRandomString(3);

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

            HomePage homePage = new HomePage(driver);
            String HomeWindow = driver.CurrentWindowHandle;
            homePage.ClickCreateIMG();
            homePage.ClickFrontCounterContactActivityRibbonButton();

            FrontCounterContactPage frontCounterContactPage = new FrontCounterContactPage(driver);
            frontCounterContactPage.ClickPageTitle();

            // Assign a Client and fill in all possisble fields.
            frontCounterContactPage.SetSelectSubjectValue("Bond existence");
            frontCounterContactPage.SetSubjectValue(FrontCounterActivity1);
            frontCounterContactPage.SetClientName(ClientName);
            frontCounterContactPage.ClickSaveCloseButton();

            driver = driver.SwitchTo().Window(HomeWindow);
            homePage.ClickCreateIMG();
            homePage.ClickFrontCounterContactActivityRibbonButton();

            frontCounterContactPage = new FrontCounterContactPage(driver);
            frontCounterContactPage.ClickPageTitle();

            // Assign a Client and fill in all possisble fields.
            frontCounterContactPage.SetSelectSubjectValue("Bond existence");
            frontCounterContactPage.SetSubjectValue(FrontCounterActivity2);
            frontCounterContactPage.SetClientName(ClientName);
            frontCounterContactPage.ClickSaveCloseButton();

            driver.Quit();
            driver = null;

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

            homePage = new HomePage(driver);
            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.PopulateNewClient("Test");
            clientPage.ClickSaveButton();
            string ClientID = clientPage.GetClientID();
            clientPage.ClickSaveCloseButton();

            driver = driver.SwitchTo().Window(HomeWindow);
            homePage.HoverCRMRibbonTab();
            homePage.ClickClientServicesRibbonButton();
            homePage.HoverClientServicesRibbonTab();
            homePage.ClickClientActivitiesRibbonButton();

            // Open an existing Front Counter Contact activity (not created by your test user) from the list.
            ActivitiesSearchPage activitiesSearchPage = new ActivitiesSearchPage(driver);
            string BaseWindow = driver.CurrentWindowHandle;
            activitiesSearchPage.SetTenancyRequestSearchText(FrontCounterActivity1);

            Table table = new Table(activitiesSearchPage.GetSearchResultTable());
            table.ClickCellValue("Activity Type", "Front Counter Contact", "Subject");

            frontCounterContactPage = new FrontCounterContactPage(driver);
            // Modify an aspect of the activity - add a client and change the description and then save the Activity.
            frontCounterContactPage.SetClientName("TEST");
            frontCounterContactPage.SetDescription("Modify Front Counter Activity");
            frontCounterContactPage.ClickSaveButton();
            frontCounterContactPage.ClickPageTitle();

            // Activity saves without error.
            StringAssert.Contains(frontCounterContactPage.GetClientName(), "TEST");
            StringAssert.Contains(frontCounterContactPage.GetDescription(), "Modify Front Counter Activity");

            frontCounterContactPage.ClickSaveCloseButton();

            // Open another Front Counter Contact which has not been created by your test user.
            driver = driver.SwitchTo().Window(BaseWindow);
            activitiesSearchPage = new ActivitiesSearchPage(driver);
            activitiesSearchPage.SetTenancyRequestSearchText(FrontCounterActivity2);

            table = new Table(activitiesSearchPage.GetSearchResultTable());
            table.ClickCellValue("Activity Type", "Front Counter Contact", "Subject");

            frontCounterContactPage = new FrontCounterContactPage(driver);

            // Close the Front Counter Contact.Activity Closes without any error
            frontCounterContactPage.ClickPageTitle();
            Thread.Sleep(500);
            frontCounterContactPage.ClickCloseFrontCounterContactButton();
            Thread.Sleep(500);
            frontCounterContactPage.ClickDialogAddButton();
            Thread.Sleep(1000);

            // Ensure that the Activity does not allow editing.
            frontCounterContactPage.ClickPageTitle();
            Assert.IsTrue(UICommon.VerifyElementLocked("subject", driver), "Subject Field is NOT locked!!!");
            Assert.IsTrue(UICommon.VerifyElementLocked("customers", driver), "customers Field is NOT locked!!!");
            Assert.IsTrue(UICommon.VerifyElementLocked("actualend", driver), "actualend Field is NOT locked!!!");
            Assert.IsTrue(UICommon.VerifyElementLocked("actualdurationminutes", driver), "Actual Duration Field is NOT locked!!!");
            Assert.IsTrue(UICommon.VerifyElementLocked("regardingobjectid", driver), "Regarding Field is NOT locked!!!");
            Assert.IsTrue(UICommon.VerifyElementLocked("rta_assistive_service_usedid", driver), "Assistive Service Field is NOT locked!!!");
            Assert.IsTrue(UICommon.VerifyElementLocked("description", driver), "Description Field is NOT locked!!!");

            // Reopen the Front Counter Contact through the Dialog.
            frontCounterContactPage.ClickStartDialogButton();
            table = new Table(frontCounterContactPage.GetProcessSearchResultTable());
            table.ClickCell("Process Name", "Re-open Front Counter Contact activity", "Created On");
            BaseWindow = driver.CurrentWindowHandle;
            frontCounterContactPage.ClickDialogAddButton();

            driver = UICommon.SwitchToNewBrowserWithTitle(driver, BaseWindow, "Re-open Front Counter Contact activity");
            ReOpenCall reOpenActivity = new ReOpenCall(driver);
            reOpenActivity.ClickNextButton();
            reOpenActivity.ClickFinishButton();

            driver = driver.SwitchTo().Window(HomeWindow);
            homePage.HoverClientServicesRibbonTab();
            homePage.ClickClientActivitiesRibbonButton();

            // Open an existing Front Counter Contact activity (not created by your test user) from the list.
            activitiesSearchPage = new ActivitiesSearchPage(driver);
            activitiesSearchPage.SetTenancyRequestSearchText(FrontCounterActivity2);

            table = new Table(activitiesSearchPage.GetSearchResultTable());
            table.ClickCellValue("Activity Type", "Front Counter Contact", "Subject");

            frontCounterContactPage = new FrontCounterContactPage(driver);
            frontCounterContactPage.ClickPageTitle();

            // Ensure that the Activity allows editing.
            Assert.IsFalse(UICommon.VerifyElementLocked("subject", driver), "Subject Field is locked!!!");
            Assert.IsFalse(UICommon.VerifyElementLocked("customers", driver), "customers Field is locked!!!");
            Assert.IsFalse(UICommon.VerifyElementLocked("actualend", driver), "actualend Field is locked!!!");
            Assert.IsFalse(UICommon.VerifyElementLocked("actualdurationminutes", driver), "Actual Duration Field is locked!!!");
            Assert.IsFalse(UICommon.VerifyElementLocked("regardingobjectid", driver), "Regarding Field is locked!!!");
            Assert.IsFalse(UICommon.VerifyElementLocked("rta_assistive_service_usedid", driver), "Assistive Service Field is locked!!!");
            Assert.IsFalse(UICommon.VerifyElementLocked("description", driver), "Description Field is locked!!!");

            frontCounterContactPage.SetDescription("Description updated after reopening activity");
            frontCounterContactPage.ClickPageTitle();

            StringAssert.Contains(frontCounterContactPage.GetDescription(), "Description updated after reopening activity");
        }
        public void ATC3313_CRMInvestigationAddAndDeactivateCaseParty()
        {
            User user = this.environment.GetUser(SecurityRole.InvestigationOfficer);
            new LoginDialog().Login(user.Id, user.Password);
            string ClientName = "CLIENT CASE" + UICommon.GetRandomString(3);

            // Create Investigation Case
            HomePage homePage = new HomePage(driver);
            string HomeWindowInv = driver.CurrentWindowHandle;
            homePage.HoverCRMRibbonTab();
            homePage.ClickInvestigationsRibbonButton();
            homePage.HoverInvestigationsRibbonTab();
            homePage.ClickInvestigationsCasesRibbonButton();

            // Verify that Investigation Officer is able to record Phone call for Investigation Case
            InvestigationCaseSearchPage investigationsCaseSearchPage = new InvestigationCaseSearchPage(driver);
            investigationsCaseSearchPage.ClickNewInvestigationCaseButton();

            // Create new Investigation case
            InvestigationCasePage investigationCasePage = new InvestigationCasePage(driver);
            investigationCasePage.ClickSaveButton();
            String investigationID = investigationCasePage.GetInvestigationCaseNumber();

            string InvWindow = driver.CurrentWindowHandle;

            IWebDriver ClientDriver = null;
            // Spawn a new window and open a Client record
            if (Properties.Settings.Default.BROWSER == BrowserType.Ie)
            {
                ClientDriver = new BrowserContext().WebDriver;
                this.environment = TestEnvironment.GetTestEnvironment();
            }

            ClientDriver.Navigate().GoToUrl(this.environment.Url);
            new LoginDialog().Login(user.Id, user.Password);

            // Create new Client Profile
            homePage = new HomePage(ClientDriver);
            string HomeWindowClient = ClientDriver.CurrentWindowHandle;
            homePage.HoverCRMRibbonTab();
            homePage.ClickClientServicesRibbonButton();
            homePage.HoverClientServicesRibbonTab();
            homePage.ClickClientsRibbonButton();

            ClientsSearchPage clientsSearchPage = new ClientsSearchPage(ClientDriver);
            Trace.Listeners.Add(new TextWriterTraceListener("TextWriterOutput.log", "myListener"));
            Trace.TraceInformation("Add Client Case Party start:" + DateTime.Now.ToString("ddMMyyyyhhmmssffff"));
            Trace.Flush();

            clientsSearchPage.ClickNewClientButton();

            ClientPage clientPage = new ClientPage(ClientDriver);
            clientPage.ClickPageTitle();
            clientPage.PopulateNewClient(ClientName);
            clientPage.ClickSaveCloseButton();
            string ClientWindow = ClientDriver.CurrentWindowHandle;

            // ADD the Client from the second open window as a Case Party to the Investigation Case
            driver.SwitchTo().Window(InvWindow);
            investigationCasePage = new InvestigationCasePage(driver);
            string BaseWindow = driver.CurrentWindowHandle;
            investigationCasePage.ClickAddCasePartyRecordButton();

            investigationCasePage.SwitchNewBrowserWithTitle(driver, BaseWindow, "Case Party");

            CasePartyPage casePartyPage = new CasePartyPage(driver);
            casePartyPage.ClickPageTitle();
            casePartyPage.ClickPartyType();
            Assert.IsTrue(casePartyPage.VerifyCasePartyTypeExists("Bond Contributor"), "Bond Contributor option not seen!!!");
            Assert.IsTrue(casePartyPage.VerifyCasePartyTypeExists("Tenant"), "Tenant option not seen!!!");
            Assert.IsTrue(casePartyPage.VerifyCasePartyTypeExists("Resident"), "Resident option not seen!!!");
            Assert.IsTrue(casePartyPage.VerifyCasePartyTypeExists("Agent"), "Agent option not seen!!!");
            Assert.IsTrue(casePartyPage.VerifyCasePartyTypeExists("Lessor"), "Lessor option not seen!!!");
            Assert.IsTrue(casePartyPage.VerifyCasePartyTypeExists("Rooming Accommodation Provider"), "Rooming Accommodation Provider option not seen!!!");
            Assert.IsTrue(casePartyPage.VerifyCasePartyTypeExists("Student Accommodation Provider"), "Student Accommodation Provider option not seen!!!");
            Assert.IsTrue(casePartyPage.VerifyCasePartyTypeExists("Moveable Dwelling Provider"), "Moveable Dwelling Provider option not seen!!!");
            Assert.IsTrue(casePartyPage.VerifyCasePartyTypeExists("Community Housing Organisation"), "Community Housing Organisation option not seen!!!");
            Assert.IsTrue(casePartyPage.VerifyCasePartyTypeExists("Owner"), "Owner option not seen!!!");
            Trace.Listeners.Add(new TextWriterTraceListener("TextWriterOutput.log", "myListener"));
            Trace.TraceInformation("Add Case Party end:" + DateTime.Now.ToString("ddMMyyyyhhmmssffff"));
            Trace.Flush();
            casePartyPage.ClickPageTitle();
            casePartyPage.SetClientName(ClientName);
            casePartyPage.ClickSaveCloseButton();

            driver = driver.SwitchTo().Window(BaseWindow);
            investigationCasePage.CheckForErrors();
            investigationCasePage.ClickSaveCloseButton();

            // Verify new Case Management Activity is shown in the Investigation Case which documents that the Case Party was added and by whom.

            investigationsCaseSearchPage = new InvestigationCaseSearchPage(driver);
            investigationsCaseSearchPage.SetSearchRecord(investigationID);

            Table table = new Table(investigationsCaseSearchPage.GetSearchResultTable());
            table.ClickCellValue("Case Number", investigationID, "Case Number");
            driver = driver.SwitchTo().Window(BaseWindow);
            investigationCasePage.ClickPageTitle();
            table = new Table(investigationCasePage.GetActivitiesSearchResultTable());
            StringAssert.Contains(table.GetCellContainsValue("Subject", "Case party " + ClientName + " added to case " + investigationID, "Activity Status"), "Completed");
            InvWindow = driver.CurrentWindowHandle;

            //Client window
            ClientDriver = ClientDriver.SwitchTo().Window(ClientWindow);
            clientsSearchPage = new ClientsSearchPage(ClientDriver);
            clientsSearchPage.SetClientSearchText(ClientName);

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

            clientPage = new ClientPage(ClientDriver);
            Thread.Sleep(3000);
            clientPage.ClickSeeRecordsAssociatedWithThisViewButton("Activities");
            clientPage.SwitchToFrame();
            clientPage.SetPageFilterList("All Activities", ClientDriver);
            clientPage.SetFilterOnList("All", ClientDriver);
            table = new Table(clientPage.GetActivitiesAssociatedViewTable(ClientDriver));
            StringAssert.Contains(table.GetCellValue("Subject", "Case party " + ClientName + " added to case " + investigationID, "Activity Status"), "Completed");
            ClientWindow = ClientDriver.CurrentWindowHandle;

            // DEACTIVATE the Case Party by opening the Case Party Associated View and running the Dialog.
            driver = driver.SwitchTo().Window(InvWindow);
            investigationCasePage = new InvestigationCasePage(driver);
            investigationCasePage.ClickPageTitle();
            table = new Table(investigationCasePage.GetCasePartyTable());
            table.ClickCellContainsValueEnterRow("Client", ClientName, "Party Type");

            casePartyPage = new CasePartyPage(driver);
            casePartyPage.ClickPageTitle();
            casePartyPage.ClickSaveButton();
            casePartyPage.ClickStartDialog();
            table = new Table(casePartyPage.GetProcessSearchResultTable());
            table.ClickCell("Process Name", "INV: Deactivate case party", "Created On");
            BaseWindow = driver.CurrentWindowHandle;
            casePartyPage.ClickDialogAddButton();

            driver = UICommon.SwitchToNewBrowserWithTitle(driver, BaseWindow, "INV:");

            INVPage INV = new INVPage(driver);
            INV.ClickNextButton();
            INV.ClickFinishButton();

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

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

            table = new Table(investigationCasePage.GetActivitiesSearchResultTable());
            StringAssert.Contains(table.GetCellContainsValue("Subject", "Case party " + ClientName + " removed from case " + investigationID, "Activity Status"), "Completed");

            // A new Case Management Activity is shown in the Client which documents that the Case Party was removed and by whom.

            ClientDriver = ClientDriver.SwitchTo().Window(ClientWindow);
            ClientDriver = ClientDriver.SwitchTo().Window(HomeWindowClient);
            homePage.HoverCRMRibbonTab();
            homePage.ClickClientServicesRibbonButton();
            homePage.HoverClientServicesRibbonTab();
            homePage.ClickClientsRibbonButton();

            clientsSearchPage = new ClientsSearchPage(ClientDriver);
            clientsSearchPage.SetClientSearchText(ClientName);

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

            clientPage = new ClientPage(ClientDriver);
            clientPage.ClickPageTitle();
            clientPage.ClickSeeRecordsAssociatedWithThisViewButton("Activities");
            clientPage.SwitchToFrame();
            clientPage.SetPageFilterList("All Activities", ClientDriver);
            clientPage.SetFilterOnList("All", ClientDriver);
            table = new Table(clientPage.GetActivitiesAssociatedViewTable(ClientDriver));
            StringAssert.Contains(table.GetCellValue("Subject", "Case party " + ClientName + " removed from case " + investigationID, "Activity Status"), "Completed");
        }
        public void ATC4413_CRMClientAgreedtoEmailCorrespondencenewclientsettoyes()
        {
            //Login in as role
            User user = this.environment.GetUser(SecurityRole.Default);
            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.ClickNewClientButton();

            ClientPage clientPage = new ClientPage(driver);
            clientPage.ClickPageTitle();
            clientPage.ClickPreferencesTab();
            StringAssert.Contains(clientPage.GetEmailCorrespondenceValue(), "No");
            clientPage.SetEmailCorrespondenceValue("Yes");

            clientPage.PopulateNewClient("EmailCorrespondenceTest");
            clientPage.ClickSaveButton();
            string clientId = clientPage.GetClientID();

            clientPage.ClickSaveCloseButton();
        }