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 ATC6737_CRMGeneralCaseClienttobeOptional()
        {
            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.ClickInvestigationsGeneralCasesRibbonButton();

            InvestigationGeneralCaseSearchPage investigationsGeneralCaseSearchPage = new InvestigationGeneralCaseSearchPage(driver);

            investigationsGeneralCaseSearchPage.ClickNewGeneralCaseButton();

            InvestigationGeneralCasePage investigationGeneralCasePage = new InvestigationGeneralCasePage(driver);
            investigationGeneralCasePage.ClickPageTitle();

            investigationGeneralCasePage.SetTitle("Test client N/A - " + DateTime.Now);
            investigationGeneralCasePage.SetClientName("-NOT APPLICABLE-");
            investigationGeneralCasePage.SetType("Complaint");
            investigationGeneralCasePage.ClickSaveButton();
            investigationGeneralCasePage.GetGeneralCaseNumber();
        }
        public void ATC4448_CRMInvestigationVerifyFilterOnInvestigatorName()
        {
            #region Start Up Excel
            MyBook = MyApp.Workbooks.Open(DatasourceDir + @"\Investigations.xlsx", 0, false, 5, "", "", true, Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
            MySheet = (Excel.Worksheet)MyBook.Sheets[Properties.Settings.Default.ENVIRONMENT.ToString()];
            MyRange = MySheet.UsedRange;

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

            string clientName = MyRange.Cells[MyRow, InvestigationSchema.GetColumnIndex(ColumnName.CLIENT_NAME)].Value;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            this.TestSetup();

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            InvestigationGeneralCaseSearchPage investigationsGeneralCaseSearchPage = new InvestigationGeneralCaseSearchPage(driver);

            investigationsGeneralCaseSearchPage.ClickNewGeneralCaseButton();

            InvestigationGeneralCasePage investigationGeneralCasePage = new InvestigationGeneralCasePage(driver);
            investigationGeneralCasePage.ClickPageTitle();

            investigationGeneralCasePage.SetTitle("Test client N/A - " + DateTime.Now);
            investigationGeneralCasePage.SetClientName("-NOT APPLICABLE-");
            investigationGeneralCasePage.SetType("Complaint");
            investigationGeneralCasePage.SetReceivedDate((DateTime.Now.AddDays(1)).ToString("dd/MM/yyyy"));
            StringAssert.Contains(investigationGeneralCasePage.GetReceivedDateErrorMessage(), "Invalid date entered for Received Date");
            investigationGeneralCasePage.SetReceivedDate((DateTime.Now).ToString("dd/MM/yyyy"));

            investigationGeneralCasePage.ClickSaveButton();
            investigationGeneralCasePage.GetGeneralCaseNumber();
        }