public void ATC3308_CRMInvestigationRecordPhoneCallActivityOnInvestigationsCase()
        {
            //Login in as 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.ClickInvestigationsRibbonButton();
            homePage.HoverInvestigationsRibbonTab();
            homePage.ClickInvestigationsCasesRibbonButton();

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

            InvestigationCasePage investigationCasePage = new InvestigationCasePage(driver);
            string BaseWindow = driver.CurrentWindowHandle; //Records the current window handle
            investigationCasePage.ClickSaveButton();
            String investigationID = investigationCasePage.GetInvestigationCaseNumber();
            Thread.Sleep(1000);
            investigationCasePage.ClickActivitiesAddButton();
            investigationCasePage.ClickAddActivity("Phone Call");
            Thread.Sleep(2000);

            //Add new Phone Call
            String subject = "New Phone Call";
            driver = investigationCasePage.SwitchNewBrowser(driver, BaseWindow);
            PhoneCallPage phoneCall = new PhoneCallPage(driver);
            Thread.Sleep(100);
            phoneCall.ClickPageTitle();
            phoneCall.SetSelectSubjectValue("Bond balance enquiry");
            phoneCall.SetSubject(subject);
            phoneCall.SetRecipient("BLAIR TEST");
            phoneCall.ClickSaveButton();
            phoneCall.ClickMarkCompleteButton();

            //Verify Phone Call details
            driver = driver.SwitchTo().Window(BaseWindow);
            investigationCasePage = new InvestigationCasePage(driver);
            investigationCasePage.ClickPageTitle();
            Table table = new Table(investigationCasePage.GetActivitiesSearchResultTable());
            Thread.Sleep(1000);
            Assert.AreEqual(subject,table.GetCellValue("Activity Type","Phone Call","Subject"));
            Assert.AreEqual("Completed", table.GetCellValue("Subject", subject, "Activity Status"));

            //Re-open Phone Call
            table.SelectTableRow("Activity Type", "Phone Call");
            phoneCall = new PhoneCallPage(driver);
            phoneCall.ClickStartDialogButton();
            table = new Table(phoneCall.GetProcessSearchResultTable());
            table.ClickCell("Process Name", "Re-open Phone Call Activity", "Created On");
            phoneCall.ClickDialogAddButton();
            Thread.Sleep(1000);

            driver = UICommon.SwitchToNewBrowserWithTitle(driver, BaseWindow, "Re-open Phone call Activity");

            ReOpenCall reOpenPhoneCall = new ReOpenCall(driver);
            reOpenPhoneCall.ClickNextButton();
            reOpenPhoneCall.ClickFinishButton();

            driver = driver.SwitchTo().Window(HomeWindow);
            driver.Navigate().Back();

            //Verify Reopned Phone call
            driver = driver.SwitchTo().Window(BaseWindow);
            investigationCasePage = new InvestigationCasePage(driver);
            table = new Table(investigationCasePage.GetActivitiesSearchResultTable());
            Thread.Sleep(1000);
            Assert.AreEqual("Open", table.GetCellValue("Subject", subject, "Activity Status"));

            table.SelectTableRow("Activity Type", "Phone Call");

            //Amend Phone call
            phoneCall = new PhoneCallPage(driver);
            String newSubject = "Amend Phone Call";
            phoneCall.SetSubject(newSubject);
            phoneCall.ClickSaveCloseButton();

            //Verify Amended Phone call details
            driver = driver.SwitchTo().Window(BaseWindow);
            investigationCasePage = new InvestigationCasePage(driver);
            table = new Table(investigationCasePage.GetActivitiesSearchResultTable());
            Thread.Sleep(1000);
            Assert.AreEqual(newSubject, table.GetCellValue("Activity Type", "Phone Call", "Subject"));
            table.SelectTableRow("Activity Type", "Phone Call");

            //Cancel Phone Call
            phoneCall = new PhoneCallPage(driver);
            phoneCall.ClickPageTitle();
            phoneCall.ClickClosePhoneCallButton();
            phoneCall.ConfirmDeactivation("Canceled");
            phoneCall.ClickConfirmDeactivationCloseButton();
            driver = driver.SwitchTo().Window(HomeWindow);
            driver.Navigate().Back();

            //Verify Canceled phone call details
            driver = driver.SwitchTo().Window(BaseWindow);
            investigationCasePage = new InvestigationCasePage(driver);
            table = new Table(investigationCasePage.GetActivitiesSearchResultTable());
            Assert.AreEqual("Canceled", table.GetCellValue("Subject", newSubject, "Activity Status"));
        }
        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");
        }