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
        }