public void ATC3316_CRMInvestigationVerifyRelatedActivitiesOwnerUpdation()
        {
            #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();

            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();

            //Email
            investigationCasePage.ClickActivitiesAddButton();
            investigationCasePage.ClickAddActivity("Email");
            Thread.Sleep(1000);
            driver = investigationCasePage.SwitchNewBrowser(driver, BaseWindow);
            Thread.Sleep(2000);
            EmailPage emailPage = new EmailPage(driver);
            emailPage.ClickPageTitle();
            emailPage.SetToValueText(clientName);
            Thread.Sleep(500);
            emailPage.SetSubjectValueText("Test 3316 Email");
            emailPage.ClickSaveCloseIMG();
            Thread.Sleep(2000);
            driver = driver.SwitchTo().Window(BaseWindow);

            //Fax
            investigationCasePage.ClickPageTitle();
            investigationCasePage.ClickActivitiesAddButton();
            investigationCasePage.ClickAddActivity("Fax");
            Thread.Sleep(1000);
            driver = investigationCasePage.SwitchNewBrowser(driver, BaseWindow);
            Thread.Sleep(2000);
            FaxPage faxPage = new FaxPage(driver);
            faxPage.ClickPageTitle();
            faxPage.SetSubjectValue("Test 3316 Fax");
            faxPage.ClickSaveCloseButton();
            Thread.Sleep(2000);
            driver = driver.SwitchTo().Window(BaseWindow);

            //Letter
            investigationCasePage.ClickPageTitle();
            investigationCasePage.ClickActivitiesAddButton();
            investigationCasePage.ClickAddActivity("Letter");
            Thread.Sleep(1000);
            driver = investigationCasePage.SwitchNewBrowser(driver, BaseWindow);
            Thread.Sleep(1000);
            LetterPage letterPage = new LetterPage(driver);
            letterPage.ClickPageTitle();
            letterPage.SetSubjectValue("Test 3316 Letter");
            letterPage.ClickSaveButton();
            letterPage.ClickSaveCloseButton();
            Thread.Sleep(2000);
            driver = driver.SwitchTo().Window(BaseWindow);

            //Phone Call
            investigationCasePage.ClickPageTitle();
            investigationCasePage.ClickActivitiesAddButton();
            investigationCasePage.ClickAddActivity("Phone Call");
            Thread.Sleep(1000);
            driver = investigationCasePage.SwitchNewBrowser(driver, BaseWindow);
            Thread.Sleep(2000);
            PhoneCallPage phoneCall = new PhoneCallPage(driver);
            Thread.Sleep(100);
            phoneCall.ClickPageTitle();
            phoneCall.SetSelectSubjectValue("Bond balance enquiry");
            phoneCall.SetSubject("Test 3316 Phone Call");
            Thread.Sleep(500);
            phoneCall.SetRecipient(clientName);
            phoneCall.ClickSaveCloseButton();
            Thread.Sleep(2000);
            driver = driver.SwitchTo().Window(BaseWindow);

            // Client Management Activity
            investigationCasePage.ClickPageTitle();
            investigationCasePage.ClickActivitiesAddButton();
            investigationCasePage.ClickAddActivity("Client Management Activity");
            Thread.Sleep(1000);
            driver = investigationCasePage.SwitchNewBrowser(driver, BaseWindow);
            Thread.Sleep(2000);
            ClientManagementActivityPage clientManagementActivityPage = new ClientManagementActivityPage(driver);
            clientManagementActivityPage.ClickPageTitle();
            clientManagementActivityPage.SetSubjectValue("Test 3316 Client Management Activity");
            clientManagementActivityPage.ClickSaveCloseButton();
            Thread.Sleep(2000);
            driver = driver.SwitchTo().Window(BaseWindow);

            // Front Counter Contact
            investigationCasePage.ClickPageTitle();
            investigationCasePage.ClickActivitiesAddButton();
            investigationCasePage.ClickAddActivity("Front Counter Contact");
            Thread.Sleep(2000);
            driver = investigationCasePage.SwitchNewBrowser(driver, BaseWindow);
            Thread.Sleep(1000);
            FrontCounterContactPage frontCounterContactPage = new FrontCounterContactPage(driver);
            frontCounterContactPage.SetSubjectValue("Test 3316 Front Counter Contact");
            frontCounterContactPage.ClickSaveCloseButton();
            Thread.Sleep(2000);
            driver = driver.SwitchTo().Window(BaseWindow);

            // Task
            investigationCasePage.ClickPageTitle();
            investigationCasePage.ClickActivitiesAddButton();
            investigationCasePage.ClickAddTaskButton("Task");
            Thread.Sleep(1000);
            driver = investigationCasePage.SwitchNewBrowser(driver, BaseWindow);
            Thread.Sleep(500);
            TaskPage taskPage = new TaskPage(driver);
            taskPage.ClickPageTitle();
            taskPage.SetSelectSubjectValue("Bond existence");
            taskPage.ClickSaveCloseButton();
            Thread.Sleep(2000);
            driver = driver.SwitchTo().Window(BaseWindow);

            // Recurring Appointment
            investigationCasePage.ClickPageTitle();
            investigationCasePage.ClickActivitiesAddButton();
            investigationCasePage.ClickAddActivity("Appointment");
            Thread.Sleep(1000);
            driver = investigationCasePage.SwitchNewBrowser(driver, BaseWindow);
            Thread.Sleep(2000);
            AppointmentPage appointmentPage = new AppointmentPage(driver);
            string AppWindow = driver.CurrentWindowHandle;
            appointmentPage.ClickPageTitle();
            appointmentPage.SetStartRange(DateTime.Today.AddDays(1).ToString("dd/MM/yyyy"));
            appointmentPage.ClickPageTitle();
            appointmentPage.ClickRecurrenceButton();
            appointmentPage.ClickSetButton();
            driver = driver.SwitchTo().Window(AppWindow);
            appointmentPage = new AppointmentPage(driver);
            appointmentPage.ClickPageTitle();
            appointmentPage.SetSubjectValue("Test 3316 Recurring Appointment");
            appointmentPage.ClickSaveCloseButton();
            Thread.Sleep(2000);
            driver = driver.SwitchTo().Window(BaseWindow);

            // Appointment
            investigationCasePage.ClickPageTitle();
            investigationCasePage.ClickActivitiesAddButton();
            investigationCasePage.ClickAddActivity("Appointment");
            Thread.Sleep(1000);
            driver = investigationCasePage.SwitchNewBrowser(driver, BaseWindow);
            Thread.Sleep(2000);
            appointmentPage = new AppointmentPage(driver);
            appointmentPage.ClickPageTitle();
            appointmentPage.SetSubjectValue("Test 3316 Appointment");
            appointmentPage.ClickSaveCloseButton();
            Thread.Sleep(2000);
            driver = driver.SwitchTo().Window(BaseWindow);

            // Change the owner value
            investigationCasePage.ClickPageTitle();
            investigationCasePage.SetOwnerValue("IMSTestU04");
            investigationCasePage.ClickSaveCloseButton();
            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();
            investigationCasePage.ClickSeeRecordsAssociatedWithThisViewButton("Activities");
            Thread.Sleep(1000);

            investigationCasePage.SetActivitiesSearchText("Test 3316 Email");
            table = new Table(investigationCasePage.GetActivitiesAssociatedViewTable());
            StringAssert.Contains(table.GetCellContainsValue("Subject", "Test 3316 Email", "Owner"), "IMSTestU04");

            investigationCasePage.SetActivitiesSearchText("Test 3316 Fax");
            table = new Table(investigationCasePage.GetActivitiesAssociatedViewTable());
            StringAssert.Contains(table.GetCellContainsValue("Subject", "Test 3316 Fax", "Owner"), "IMSTestU04");

            investigationCasePage.SetActivitiesSearchText("Test 3316 Letter");
            table = new Table(investigationCasePage.GetActivitiesAssociatedViewTable());
            StringAssert.Contains(table.GetCellContainsValue("Subject", "Test 3316 Letter", "Owner"), "IMSTestU04");

            investigationCasePage.SetActivitiesSearchText("Test 3316 Phone Call");
            table = new Table(investigationCasePage.GetActivitiesAssociatedViewTable());
            StringAssert.Contains(table.GetCellContainsValue("Subject", "Test 3316 Phone Call", "Owner"), "IMSTestU04");

            investigationCasePage.SetActivitiesSearchText("Test 3316 Client Management Activity");
            table = new Table(investigationCasePage.GetActivitiesAssociatedViewTable());
            StringAssert.Contains(table.GetCellContainsValue("Subject", "Test 3316 Client Management Activity", "Owner"), "IMSTestU04");

            investigationCasePage.SetActivitiesSearchText("Test 3316 Front Counter Contact");
            table = new Table(investigationCasePage.GetActivitiesAssociatedViewTable());
            StringAssert.Contains(table.GetCellContainsValue("Subject", "Test 3316 Front Counter Contact", "Owner"), "IMSTestU04");

            investigationCasePage.SetActivitiesSearchText(investigationID + ": Bond existence");
            table = new Table(investigationCasePage.GetActivitiesAssociatedViewTable());
            StringAssert.Contains(table.GetCellContainsValue("Subject", investigationID + ": Bond existence", "Owner"), "IMSTestU04");

            investigationCasePage.SetActivitiesSearchText("Test 3316 Appointment");
            table = new Table(investigationCasePage.GetActivitiesAssociatedViewTable());
            StringAssert.Contains(table.GetCellContainsValue("Subject", "Test 3316 Appointment", "Owner"), "IMSTestU04");

            investigationCasePage.SetActivitiesSearchText("Test 3316 Recurring Appointment");
            table = new Table(investigationCasePage.GetActivitiesAssociatedViewTable());
            StringAssert.Contains(table.GetCellContainsValue("Subject", "Test 3316 Recurring Appointment", "Owner"), "IMSTestU04");

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

            // Create new investigation case
            InvestigationCaseSearchPage investigationCaseSearchPage = new InvestigationCaseSearchPage(driver);
            investigationCaseSearchPage.ClickNewInvestigationCaseButton();

            InvestigationCasePage investigationCasePage = new InvestigationCasePage(driver);
            investigationCasePage = new InvestigationCasePage(driver);
            investigationCasePage.ClickSaveButton();
            string investigationID = investigationCasePage.GetInvestigationCaseNumber();
            investigationCasePage.ClickSaveCloseButton();

            // Search for the Investigation Case ID
            investigationCaseSearchPage = new InvestigationCaseSearchPage(driver);
            investigationCaseSearchPage.SetSearchRecord(investigationID);

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

            driver.Navigate().Refresh();
            Thread.Sleep(1000);

            investigationCasePage = new InvestigationCasePage(driver);
            string BaseWindow = driver.CurrentWindowHandle; //Records the current window handle
            investigationCasePage.SetPageFilterList("All Activities");
            Thread.Sleep(1000);
            table = new Table(investigationCasePage.GetActivitiesSearchResultTable());

            // Add 1st completed activity
            investigationCasePage.ClickActivitiesAddButton();
            investigationCasePage.ClickAddTaskButton("Task");

            //Enter Request Party details
            driver = investigationCasePage.SwitchNewBrowser(driver, BaseWindow);
            TaskPage taskPage = new TaskPage(driver);
            Thread.Sleep(100);
            taskPage.ClickPageTitle();
            taskPage.SetSelectSubjectValue("Relevant address added");
            taskPage.ClickSaveButton();
            taskPage.ClickMarkCompleteButton();

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

            // Add 2nd completed activity
            investigationCasePage.ClickPageTitle();
            investigationCasePage.ClickActivitiesAddButton();
            BaseWindow = driver.CurrentWindowHandle; //Records the current window handle
            investigationCasePage.ClickAddTaskButton("Task");

            //Enter Request Party details
            driver = investigationCasePage.SwitchNewBrowser(driver, BaseWindow);
            Thread.Sleep(100);
            taskPage = new TaskPage(driver);

            taskPage.ClickPageTitle();
            taskPage.SetSelectSubjectValue("Allocate to investigator");
            taskPage.ClickSaveButton();
            taskPage.ClickMarkCompleteButton();

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

            investigationCasePage.ClickPageTitle();
            investigationCasePage.SetPageFilterList("All Activities");
            Thread.Sleep(1000);
            table = new Table(investigationCasePage.GetActivitiesSearchResultTable());

            // Verify that we are having 2 completed and 2 open activities
            StringAssert.Contains(table.GetCellContainsValue("Subject", "Relevant address added", "Activity Status"), "Completed");
            StringAssert.Contains(table.GetCellContainsValue("Subject", "Allocate to investigator", "Activity Status"), "Completed");
            StringAssert.Contains(table.GetCellContainsValue("Subject", investigationID + ": Scan documents", "Activity Status"), "Open");
            StringAssert.Contains(table.GetCellContainsValue("Subject", investigationID + ": Add parties", "Activity Status"), "Open");
            StringAssert.Contains(table.GetCellContainsValue("Subject", investigationID + ": Submit for initial assessment", "Activity Status"), "Open");

            Assert.AreEqual(5, table.GetRowCount()-1, "Additional activities seen");

            // Now try to close the case
            investigationCasePage.ClickStartDialogButton();
            table = new Table(investigationCasePage.GetProcessSearchResultTable());
            table.ClickCell("Process Name", "INV: Close investigation case", "Created On");
            BaseWindow = driver.CurrentWindowHandle; //Records the current window handle
            investigationCasePage.ClickDialogAddButton();

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

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

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

            // Now Investigation case is closed.. verify that this case is not seen in active Investigation case
            investigationCasePage.ClickSaveCloseButton();

            investigationCaseSearchPage = new InvestigationCaseSearchPage(driver);
            investigationCaseSearchPage.SetPageFilterList("Active Investigation Cases");

            investigationCaseSearchPage.SetSearchRecord(investigationID);

            StringAssert.Contains(driver.FindElement(By.ClassName("ms-crm-List-MessageText")).Text, "No Investigation Case records are available in this view.");
        }
        public void ATC6710_CRMMasterCaseInvestigationCaseOptionalTasks()
        {
            string INVNumber;
            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.ClickInvestigationsMasterCasesRibbonButton();

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

            InvestigationMasterCasePage investigationMasterCasePage = new InvestigationMasterCasePage(driver);
            investigationMasterCasePage.ClickSaveButton();
            INVNumber = investigationMasterCasePage.GetInvestigationMasterCaseNumber();
            investigationMasterCasePage.ClickSaveCloseButton();
            investigationMasterCasesSearchPage = new InvestigationMasterCaseSearchPage(driver);
            investigationMasterCasesSearchPage.SetInvestigationSearchText(INVNumber);
            Table table = new Table(investigationMasterCasesSearchPage.GetSearchResultTable());
            table.ClickCellContainsValueEnterRow("Master Case ID", INVNumber, "Master Case ID");
            investigationMasterCasePage = new InvestigationMasterCasePage(driver);
            investigationMasterCasePage.ClickPageTitle();
            investigationMasterCasePage.ClickActivitiesAddButton();
            investigationMasterCasePage.ClickCRMToolbar();
            string BaseWindow = driver.CurrentWindowHandle; //Records the current window handle
            investigationMasterCasePage.ClickAddTaskButton("Task");
            Thread.Sleep(3000);
            //Enter Request Party details
            driver = investigationMasterCasePage.SwitchNewBrowserWithTitle(driver, BaseWindow, "Task");

            TaskPage taskPage = new TaskPage(driver);
            string[] subjects = new string[] {
                "Relevant address added",
                "Allocate to investigator",
                "Relevant bond background searches",
                "Follow-up request to be sent to complainant(s)",
                "Request to be sent (compelled by law)",
                "Follow-up request to be sent to third party",
                "Visit complainant",
                "Visit other witness",
                "Visit subject premises",
                "Visit other premises",
                "Visit respondent",
                "Execute warrant(s)",
                "Follow-up request to be sent to respondent",
                "Acknowledgement to be sent to respondent",
                "Send closure letter to respondent(s)",
                "Send closure letter to complainant(s)",
                "Additional investigations required",
                "Seek executive approval to prosecute",
                "Issue PIN",
                "Awaiting PIN referral to SPER"
            };

            foreach (string i in subjects)
            {
                taskPage.ClickPageTitle();
                Thread.Sleep(2000);
                taskPage.SetSelectSubjectValue(i);
                StringAssert.Contains(taskPage.GetSubjectValue(), i);

            }

            taskPage.ClickSaveCloseButton();

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

            homePage.HoverCRMRibbonTab();
            homePage.ClickInvestigationsRibbonButton();
            homePage.HoverInvestigationsRibbonTab();
            homePage.ClickInvestigationsCasesRibbonButton();

            InvestigationCaseSearchPage investigationCaseSearchPage = new InvestigationCaseSearchPage(driver);
            investigationCaseSearchPage.ClickNewInvestigationCaseButton();

            InvestigationCasePage investigationCasePage = new InvestigationCasePage(driver);
            Thread.Sleep(3000);
            investigationCasePage.ClickSaveButton();
            investigationCasePage.GetInvestigationCaseNumber();
            investigationCasePage.ClickActivitiesAddButton();
            investigationCasePage.ClickCRMToolbar();
            BaseWindow = driver.CurrentWindowHandle; //Records the current window handle
            investigationCasePage.ClickAddTaskButton("Task");
            Thread.Sleep(3000);
            //Enter Request Party details
            driver = investigationCasePage.SwitchNewBrowserWithTitle(driver, BaseWindow, "Task");

            taskPage = new TaskPage(driver);
            subjects = new string[] {
                "Relevant address added",
                "Allocate to investigator",
                "Relevant bond background searches",
                "Follow-up request to be sent to complainant(s)",
                "Request to be sent (compelled by law)",
                "Follow-up request to be sent to third party",
                "Visit complainant",
                "Visit other witness",
                "Visit subject premises",
                "Visit other premises",
                "Visit respondent",
                "Execute warrant(s)",
                "Follow-up request to be sent to respondent",
                "Acknowledgement to be sent to respondent",
                "Send closure letter to complainant(s)",
                "Send closure letter to respondent(s)",
                "Additional investigations required",
                "Seek executive approval to prosecute",
                "Issue PIN",
                "Awaiting PIN referral to SPER"
            };

            foreach (string i in subjects)
            {
                taskPage.ClickPageTitle();
                taskPage.SetSelectSubjectValue(i);
                StringAssert.Contains(taskPage.GetSubjectValue(), i);

            }

            taskPage.ClickSaveCloseButton();
            driver = driver.SwitchTo().Window(BaseWindow);
        }