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 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 ATC6834_CRMInvestigationValidateDurationWithoutReceivedDateSet()
        {
            //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.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;
            investigationCasePage.ClickPageTitle();
            investigationCasePage.ClickSaveButton();

            string investigationID = investigationCasePage.GetInvestigationCaseNumber();

            // Now close the investigation case
            investigationCasePage.ClickStartDialogButton();
            Table 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.SetDate(DateTime.Today.ToString("dd-MM-yyyy"));
            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.ClickPageTitle();
            investigationCasePage.ClickSaveCloseButton();

            investigationCaseSearchPage = new InvestigationCaseSearchPage(driver);

            investigationCaseSearchPage.SetPageFilterList("Inactive Investigation Cases");
            investigationCaseSearchPage.SetSearchRecord(investigationID);
            table = new Table(investigationCaseSearchPage.GetSearchResultTable());
            table.ClickCellValue("Case Number", investigationID, "Case Number");

            Thread.Sleep(100);

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

            // Verify the Duration field value...
            Assert.AreEqual(0, investigationCasePage.GetDurationDaysValue(), "Duration field showing wrong days");
        }
        public void ATC9200_CRMInvestigationClosingACaseWhichDoesNotHaveCasePartyShouldNotGiveError()
        {
            //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.ClickStartDialogButton();

            Table table = new Table(investigationCasePage.GetProcessSearchResultTable());
            table.ClickCell("Process Name", "INV: Close investigation case", "Created On");
            string 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);

            investigationCasePage.ClickSaveCloseButton();

            investigationCaseSearchPage = new InvestigationCaseSearchPage(driver);

            investigationCaseSearchPage.SetPageFilterList("Inactive Investigation Cases");

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

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

            Thread.Sleep(1000);

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

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

            investigationCasePage.ClickDialogAddButton();

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

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

            iNVPage.ClickNextButton();
            iNVPage.ClickFinishButton();

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

            driver.Navigate().Refresh();
            Thread.Sleep(1000);
        }
        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 ATC5286_CRMInvestigationMasterCaseAssociatedCaseStatusChange()
        {
            #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.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);
            investigationCasePage.ClickSaveButton();
            String investigationID1 = investigationCasePage.GetInvestigationCaseNumber();
            Thread.Sleep(1000);
            investigationCasePage.ClickSaveCloseButton();

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

            investigationCasePage = new InvestigationCasePage(driver);
            investigationCasePage.ClickSaveButton();
            String investigationID2 = investigationCasePage.GetInvestigationCaseNumber();
            Thread.Sleep(1000);
            investigationCasePage.ClickSaveCloseButton();
            investigationCaseSearchPage = new InvestigationCaseSearchPage(driver);

            driver = driver.SwitchTo().Window(HomeWindow);
            homePage.HoverInvestigationsRibbonTab();
            homePage.ClickInvestigationsMasterCasesRibbonButton();

            InvestigationMasterCaseSearchPage investigationMasterCasesSearchPage = new InvestigationMasterCaseSearchPage(driver);
            string BaseWindow = driver.CurrentWindowHandle;

            investigationMasterCasesSearchPage.ClickNewButton();

            InvestigationMasterCasePage investigationMasterCasePage = new InvestigationMasterCasePage(driver);
            string MasterWindow = driver.CurrentWindowHandle;
            investigationMasterCasePage.SetClientValue(clientName);
            investigationMasterCasePage.ClickSaveButton();

            String investigationMasterID = investigationMasterCasePage.GetInvestigationMasterCaseNumber();

            investigationMasterCasePage.ClickInvestigationCaseAddButton();
            investigationMasterCasePage.SetInvestigationCaseNumberToAssociateMaster(investigationID1);

            investigationMasterCasePage.ClickInvestigationCaseAddButton();
            investigationMasterCasePage.SetInvestigationCaseNumberToAssociateMaster(investigationID2);

            // Confirm user can view the current status and sub status of each linked Investigation Case
            Table table = new Table(investigationMasterCasePage.GetInvestigationCasesSearchResultTable());
            Assert.AreEqual("New case", table.GetCellValue("Case Number", investigationID1, "Investigation Status"));
            Assert.AreEqual("Creation", table.GetCellValue("Case Number", investigationID1, "Investigation Sub Status"));

            Assert.AreEqual("New case", table.GetCellValue("Case Number", investigationID2, "Investigation Status"));
            Assert.AreEqual("Creation", table.GetCellValue("Case Number", investigationID2, "Investigation Sub Status"));

            table.ClickCell("Case Number", investigationID2, "Case Number");

            investigationMasterCasePage.ClickInvestigationCaseAssociatedView();

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

            // Confirm 'Investigation Case Associated View' displayed
            Assert.AreEqual("Investigation Case Associated View", investigationMasterCasePage.GetCurrentView());

            // Select associated Investigation Case to update
            investigationMasterCasePage.SwitchToMasterCasePageFrame();

            table = new Table(investigationMasterCasePage.GetInvestigationCasesAssociatedViewTable());
            table.ClickCellValue("Case Number", investigationID2, "Case Number");

            investigationCasePage = new InvestigationCasePage(driver);
            investigationCasePage.ClickPageTitle();
            string CaseWindow = driver.CurrentWindowHandle;
            investigationCasePage.ClickRunWorkflowButton();

            // From 'Run Workflow' select 'Update Status: New Case - Creation' process

            table = new Table(investigationCasePage.GetProcessSearchResultTable());
            table.ClickCell("Process Name", "Update Status: New Case - Creation", "Created On");

            investigationCasePage.ClickDialogAddButton();
            Thread.Sleep(400);
            investigationCasePage.ClickConfirmApplicationOfWindow(BaseWindow);

            driver = driver.SwitchTo().Window(CaseWindow);
            Thread.Sleep(400);
            investigationCasePage.ClickSaveCloseButton();

            investigationMasterCasePage = new InvestigationMasterCasePage(driver);
            investigationMasterCasePage.ClickSaveCloseButton();

            investigationMasterCasesSearchPage = new InvestigationMasterCaseSearchPage(driver);
            investigationMasterCasesSearchPage.SearchRecord(investigationMasterID);
            table = new Table(investigationMasterCasesSearchPage.GetSearchResultTable());
            table.ClickCellContainsValueEnterRow("Master Case ID", investigationMasterID, "Master Case ID");

            investigationMasterCasePage = new InvestigationMasterCasePage(driver);
            table = new Table(investigationMasterCasePage.GetInvestigationCasesSearchResultTable());
            table.ClickCellValue("Case Number", investigationID2, "Case Number");

            // Confirm that Status - sub statuses updated to 'New Case - Initial assessment'

            investigationCasePage = new InvestigationCasePage(driver);
            StringAssert.Contains(investigationCasePage.GetStatus(), "New case");
            StringAssert.Contains(investigationCasePage.GetSubStatus(), "Initial assessment");

            table = new Table(investigationCasePage.GetActivitiesHeaderTable());
            table.ClickTableColumnHeader("Subject");

            table = new Table(investigationCasePage.GetActivitiesSearchResultTable());

            // Confirm mandatory tasks for Investigation Cases updated are created for that status and sub status

            StringAssert.Contains(table.GetCellContainsValue("Subject", 1), investigationID2 + ": Add parties");
            StringAssert.Contains(table.GetCellContainsValue("Subject", 2), investigationID2 + ": Allocate");
            StringAssert.Contains(table.GetCellContainsValue("Subject", 3), investigationID2 + ": Carry out initial assessment");
            StringAssert.Contains(table.GetCellContainsValue("Subject", 4), investigationID2 + ": Scan documents");
            StringAssert.Contains(table.GetCellContainsValue("Subject", 5), investigationID2 + ": Submit for initial assessment");

            Assert.AreEqual(5, table.GetRowCount() - 1, "Additional activities are displayed!!!!");

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

            InvestigationCaseSearchPage investigationCaseSearchPage = new InvestigationCaseSearchPage(driver);
            //investigationCaseSearchPage.ClickNewInvestigationCaseButton();
            investigationCaseSearchPage.SetPageFilterList("All Investigation Cases");
            Table table = new Table(investigationCaseSearchPage.GetSearchResultTable());
            table.SelectTableRow("Investigation Status", "Closed");

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

            table = new Table(investigationCasePage.GetProcessSearchResultTable());
            table.ClickCell("Process Name", "INV: Re-open investigation case", "Created On");
            string 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.ClickFinishButton();

            driver = driver.SwitchTo().Window(BaseWindow);
        }
        public void ATC4445_CRMInvestigationFutureDateNotAllowedForFinalisedDate()
        {
            //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.ClickStartDialogButton();

            Table table = new Table(investigationCasePage.GetProcessSearchResultTable());
            table.ClickCell("Process Name", "INV: Close investigation case", "Created On");
            string 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();

            string tomorrowDate = DateTime.Today.AddDays(1).ToString("dd-MM-yyyy");
            string todayDate = DateTime.Today.ToString("dd-MM-yyyy");

            iNVPage.SetDate(tomorrowDate);

            iNVPage.ClickNextButton();

            Assert.AreEqual("! WARNING !\r\n\r\nYou have entered a finalised date in the future which is not allowed. Either go back and update the finalised date or continue for the current date to be used by default.", iNVPage.GetErrorMessage());

            iNVPage.ClickPreviousButton();

            iNVPage.SetDate(todayDate);

            iNVPage.ClickNextButton();

            Assert.AreEqual("This is the end of the dialog. Click Finish to close it.", iNVPage.GetFinishMessage());

            iNVPage.ClickFinishButton();
        }
        public void ATC3330_CRMInvestigationValidateSubstatusAfterSelectingStatus()
        {
            //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);
            string BaseWindow = driver.CurrentWindowHandle; //Records the current window handles
            investigationCasePage.ClickPageTitle();
            investigationCasePage.SetStatus("Investigation current");
            investigationCasePage.ClickPageTitle();
            investigationCasePage.SetSubStatus("Conducting background searches");
            investigationCasePage.ClickPageTitle();
            investigationCasePage.ClickSaveButton();
            string investigationID = investigationCasePage.GetInvestigationCaseNumber();

            // Now close the investigation case
            investigationCasePage.ClickStartDialogButton();
            Table 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.ClickSaveButton();

            // RE-OPEN the Investigation Case by running the dialog
            investigationCasePage.ClickStartDialogButton();
            table = new Table(investigationCasePage.GetProcessSearchResultTable());
            table.ClickCell("Process Name", "INV: Re-open investigation case", "Created On");
            BaseWindow = driver.CurrentWindowHandle; //Records the current window handle
            investigationCasePage.ClickDialogAddButton();

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

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

            driver = driver.SwitchTo().Window(BaseWindow);
            investigationCasePage.ClickSaveButton();
            // Select any Status and verify that list of "Sub-status" is correctly displayed

            investigationCasePage.SetStatus("Case finalisation");
            investigationCasePage.ClickPageTitle();
            // Verify that Sub-status is cleared off and error message is thrown
            investigationCasePage.ClickSubStatusText();
            StringAssert.Contains(investigationCasePage.GetSubStatusErrorText(), "You must provide a value for Sub Status.");

            investigationCasePage.ClickPageTitle();

            investigationCasePage.ClickSubStatusSearchButton();

            Assert.IsTrue(investigationCasePage.FindSubStatusFromDropdown("Case closed discussion"));
            Assert.IsTrue(investigationCasePage.FindSubStatusFromDropdown("Close without further action"));
            Assert.IsTrue(investigationCasePage.FindSubStatusFromDropdown("Educating respondent(s)"));
            Assert.IsTrue(investigationCasePage.FindSubStatusFromDropdown("Prosecution required"));
            Assert.AreEqual(4, investigationCasePage.GetSubStatusCount());
        }
        public void ATC3328_CRMInvestigationReopenCaseProvidingAReason()
        {
            //Login in as role
            //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.ClickStartDialogButton();

            Table table = new Table(investigationCasePage.GetProcessSearchResultTable());
            table.ClickCell("Process Name", "INV: Close investigation case", "Created On");
            string 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();
            string todayDate = DateTime.Today.ToString("dd-MM-yyyy");
            iNVPage.SetDate(todayDate);
            iNVPage.ClickNextButton();
            iNVPage.ClickFinishButton();

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

            investigationCasePage.ClickSaveCloseButton();
            investigationCaseSearchPage = new InvestigationCaseSearchPage(driver);
            investigationCaseSearchPage.SetPageFilterList("Inactive Investigation Cases");

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

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

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

            investigationCasePage.ClickDialogAddButton();

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

            iNVPage = new INVPage(driver);
            iNVPage.ClickNextButton();
            String reason="Automation test";
            iNVPage.SetSubStatusReason(reason);
            iNVPage.ClickNextButton();
            iNVPage.ClickFinishButton();

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

            driver.Navigate().Refresh();
            investigationCasePage = new InvestigationCasePage(driver);
            table = new Table(investigationCasePage.GetActivitiesSearchResultTable());
            table.ClickCell("Subject", investigationID + " case re-opened: Case finalisation - Case closed discussion", "Subject");

            Thread.Sleep(1000);

            InvestigationCaseManagementActivity caseManagementActivity = new InvestigationCaseManagementActivity(driver);
            Assert.AreEqual(reason, caseManagementActivity.GetDescription());
        }
        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 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 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");
        }