public void ATC3285_CRMInvestigationMasterCaseConfirmpresenceofFieldsonform()
        {
            string investigationMasterCaseNumber;
            User user = this.environment.GetUser(SecurityRole.Investigations);
            new LoginDialog().Login(user.Id, user.Password);

            HomePage homePage = new HomePage(driver);
            homePage.HoverCRMRibbonTab();
            homePage.ClickInvestigationsRibbonButton();
            homePage.HoverInvestigationsRibbonTab();
            homePage.ClickInvestigationsMasterCasesRibbonButton();

            InvestigationMasterCaseSearchPage investigationsMasterCaseSearchPage = new InvestigationMasterCaseSearchPage(driver);

            investigationsMasterCaseSearchPage.ClickNewButton();

            InvestigationMasterCasePage investigationMasterCasePage = new InvestigationMasterCasePage(driver);

            investigationMasterCasePage.SetUnknowInvestigatorValue("Test User");
            investigationMasterCasePage.SetClientValue("BLAIR TEST");
            //investigationMasterCasePage.SetOwnerValue("IMSTestU04");
            investigationMasterCasePage.SetInvestigatorValue("IMSTestU02");
            investigationMasterCasePage.ClickSaveButton();
            investigationMasterCaseNumber = investigationMasterCasePage.GetInvestigationMasterCaseNumber();
            investigationMasterCasePage.ClickSaveCloseButton();
        }
        public void ATC6641_CRMInvestigationCaseCasePendingNominatednumberofmonthscanbeconfigured()
        {
            //Login in as role
            User user = this.environment.GetUser(SecurityRole.SystemAdministrator);
            new LoginDialog().Login(user.Id, user.Password);

            HomePage homePage = new HomePage(driver);
            homePage.HoverCRMRibbonTab();
            homePage.ClickSettingsRibbonButton();
            homePage.HoverSettingsRibbonTab();
            homePage.ClickRightScrollRibbonButton();
            homePage.ClickProcessesRibbonButton();

            ProcessesSearchPage processesSearchPage = new ProcessesSearchPage(driver);

            //processesSearchPage.ClickProcessesViewButton();

            processesSearchPage.SetProcessesSearchText("GetConfigurationValues");
            Table table = new Table(processesSearchPage.GetSearchResultTable());
            StringAssert.Contains(table.GetCellValue("Process Name", "GetConfigurationValues", "Process Name"), "GetConfigurationValues");

            string BaseWindow = driver.CurrentWindowHandle; //Records the current window handle

            table.ClickCellValue("Process Name", "GetConfigurationValues", "Process Name");

            //Enter Request Party details

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

            string title = driver.Title;

            ProcessesPage processPage = new ProcessesPage(driver);

            processPage.ClickDeactivateButton();
            WarningDialogueFramePage warningDialogueFramePage = new WarningDialogueFramePage(driver);
            warningDialogueFramePage.ClickProcessBeginButton();

            processPage.ClickActivateButton();
            warningDialogueFramePage = new WarningDialogueFramePage(driver);
            warningDialogueFramePage.ClickProcessBeginButton();

            processPage.ClickDeactivateButton();
            warningDialogueFramePage = new WarningDialogueFramePage(driver);
            warningDialogueFramePage.ClickProcessBeginButton();

            processPage.ClickActivateButton();
            warningDialogueFramePage = new WarningDialogueFramePage(driver);
            warningDialogueFramePage.ClickProcessBeginButton();

            processPage.ClickCloseButton();

            driver = driver.SwitchTo().Window(BaseWindow);
        }
        public void ATC9875_CRMTenancyRequestBLManagementTypeIsMandatory()
        {
            //Login as RBS Operations Standard User Role.
            User user = this.environment.GetUser(SecurityRole.RBSOfficer);
            new LoginDialog().Login(user.Id, user.Password);

            //Navigate to: RBS group > Tenancy Requests
            HomePage homePage = new HomePage(driver);
            homePage.HoverCRMRibbonTab();
            homePage.ClickRBSRibbonButton();
            homePage.HoverRBSRibbonTab();
            homePage.ClickRtaTenancyRequestRibbonButton();

            //To finish when I find out where new is on the page - GD
        }
        public void ATC3341_CRMInvestigationNewCaseDefaultsToNewCaseStatus()
        {
            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();

            Trace.Listeners.Add(new TextWriterTraceListener("TextWriterOutput.log", "myListener"));
            Trace.TraceInformation("Create new investigation case start:" + DateTime.Now.ToString("ddMMyyyyhhmmssffff"));
            Trace.Flush();

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

            // Create new case and validate Status and Substatus fields
            InvestigationCasePage investigationCasePage = new InvestigationCasePage(driver);
            Assert.AreEqual("New case", investigationCasePage.GetStatus());
            Assert.AreEqual("Creation", investigationCasePage.GetSubStatus());
            investigationCasePage.ClickSaveButton();
            String caseNumber=investigationCasePage.GetInvestigationCaseNumber();
            investigationCasePage.ClickSaveCloseButton();

            // Search for the newly created Investigation Case
            investigationsCaseSearchPage = new InvestigationCaseSearchPage(driver);
            investigationsCaseSearchPage.SetInvestigationSearchText(caseNumber);
            Table table = new Table(investigationsCaseSearchPage.GetSearchResultTable());
            table.ClickCellValue("Case Number", caseNumber, "Case Number");

            // Validate the activity created for New Investigation case
            investigationCasePage = new InvestigationCasePage(driver);
            StringAssert.Contains(investigationCasePage.GetInvestigationCaseNumber(), caseNumber);
            table = new Table(investigationCasePage.GetActivitiesSearchResultTable());
            StringAssert.Contains(table.GetCellContainsValue("Subject", caseNumber+": Scan documents", "Activity Status"), "Open");
            StringAssert.Contains(table.GetCellContainsValue("Subject", caseNumber + ": Add parties", "Activity Status"), "Open");
            StringAssert.Contains(table.GetCellContainsValue("Subject", caseNumber + ": Submit for initial assessment", "Activity Status"), "Open");

            Trace.Listeners.Add(new TextWriterTraceListener("TextWriterOutput.log", "myListener"));
            Trace.TraceInformation("Create new investigation case end:" + DateTime.Now.ToString("ddMMyyyyhhmmssffff"));
            Trace.Flush();
        }
        public void ATC9204_CRMInputDataToRefundRequestsAC1InputAdditionalData()
        {
            //Login as RBS Operations Standard User Role.
            User user = this.environment.GetUser(SecurityRole.RBSOfficer);
            new LoginDialog().Login(user.Id, user.Password);

            //Navigate to: RBS group > Tenancy Requests
            HomePage homePage = new HomePage(driver);
            homePage.HoverCRMRibbonTab();
            homePage.ClickRBSRibbonButton();
            homePage.HoverRBSRibbonTab();
            homePage.ClickRtaTenancyRequestRibbonButton();

            TenancyRequestsSearchPage tenancyRequestSearchPage = new TenancyRequestsSearchPage(driver);

            //Set view to Active Bond Refunds.
            tenancyRequestSearchPage.SetPageFilterList("Active Bond Refunds");

            //Double-click on record to open it.
            UICommon.DoubleClickElement(tenancyRequestSearchPage.GetSearchResultRow(), driver);

            //Ensure following fields are editable and mandatory i.e. Ensure cannot save record when cleared:
            //Assert: This field is Mandatory - Amount to be refunded per contributor (M)

            /*
             * Ensure following fields are editable and optional and requirements are reflected in software:
                - Date Tenants/residents vacated (O)
                - Expiry date of notice (O)
                - Forwarding address of every contributor (O)
                - date signed by every contributor and the managing party (O)
                - Details of Claim with Amounts (O, Claim reason list - see Picture+free text - 300 (?)
                +)
                Amounts are optional, a CRM user should be able to choose multiple reasons associated with the full amount of claim
             */

            //Modify Address and dollar values fields.

            //Select the [AUDIT HISTORY] item from the entity navigation menu in the global ribbon.

            //Inspect audit history.
        }
        public void ATC3337_CRMEntityClientConfirmvalidationofABN()
        {
            //Login in as role
            User user = this.environment.GetUser(SecurityRole.SystemAdministrator);
            new LoginDialog().Login(user.Id, user.Password);

            HomePage homePage = new HomePage(driver);
            homePage.HoverCRMRibbonTab();
            homePage.ClickClientServicesRibbonButton();
            homePage.HoverClientServicesRibbonTab();
            homePage.ClickClientsRibbonButton();

            ClientsSearchPage clientsSearchPage = new ClientsSearchPage(driver);

            clientsSearchPage.ClickNewClientButton();

            ClientPage clientPage = new ClientPage(driver);
            clientPage.ClickPageTitle();

            clientPage.SetABNACNValue("124324542747");
            clientPage.GetABNACNErrorText();

            clientPage.SetABNACNValue("7898281890n");
            clientPage.GetABNACNErrorText();

            clientPage.SetABNACNValue("78982818908");
            clientPage.GetABNACNErrorTextNotExist();

            clientPage.SetABNACNValue("005249981");
            clientPage.GetABNACNErrorTextNotExist();

            clientPage.SetARBNValue("123456789");
            clientPage.GetARBNErrorText();

            clientPage.SetARBNValue("12345678n");
            clientPage.GetARBNErrorText();

            clientPage.SetARBNValue("005249981");
            clientPage.GetARBNErrorTextNotExist();
        }
        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 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 ATC3311_CRMInvestigationVerifyActionFollowupDateRemoval()
        {
            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();

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

            // Create new case and validate Status and Substatus fields
            InvestigationCasePage investigationCasePage = new InvestigationCasePage(driver);
            investigationCasePage.ClickSaveButton();
            String caseNumber = investigationCasePage.GetInvestigationCaseNumber();
            investigationCasePage.ClickSaveCloseButton();

            // Search for the newly created Investigation Case
            investigationsCaseSearchPage = new InvestigationCaseSearchPage(driver);
            investigationsCaseSearchPage.SetInvestigationSearchText(caseNumber);
            Table table = new Table(investigationsCaseSearchPage.GetSearchResultTable());
            table.ClickCellValue("Case Number", caseNumber, "Case Number");

            // Validate Action Date and Followup date fields are removed
            investigationCasePage = new InvestigationCasePage(driver);
            investigationCasePage.ClickPageTitle();

            Assert.IsFalse(investigationCasePage.VerifyElementExists("#rta_action_date_c"), "Action Date Present with CssValue rta_action_date_c");
            Assert.IsFalse(investigationCasePage.VerifyElementExists("#rta_inv_action_dateid_c"), "Action Date Present with CssValue rta_inv_action_dateid_c");
            Assert.IsFalse(investigationCasePage.VerifyElementExists("#rta_investigation_action_dateid_c"), "Action Date Present with CssValue rta_investigation_action_dateid_c");
            Assert.IsFalse(investigationCasePage.VerifyElementExists("#action_date_c"), "Action Date Present with CssValue action_date_c");
            Assert.IsFalse(investigationCasePage.VerifyElementExists("#rta_action_dateid_c"), "Action Date Present with CssValue rta_action_dateid_c");

            Assert.IsFalse(investigationCasePage.VerifyElementExists("#rta_followup_date_c"), "Follow up date field present with CssValue: rta_followup_date_c");
            Assert.IsFalse(investigationCasePage.VerifyElementExists("#rta_inv_followup_dateid_c"), "Follow up date field present with CssValue: rta_inv_followup_dateid_c");
            Assert.IsFalse(investigationCasePage.VerifyElementExists("#rta_investigation_followup_dateid_c"), "Follow up date field present with CssValue: rta_investigation_followup_dateid_c");
            Assert.IsFalse(investigationCasePage.VerifyElementExists("#followup_date_c"), "Follow up date field present with CssValue: followup_date_c");
            Assert.IsFalse(investigationCasePage.VerifyElementExists("#rta_followup_dateid_c"), "Follow up date field present with CssValue: rta_followup_dateid_c");
        }
        public void ATC3310_CRMInvestigationAllCasesViewColumns()
        {
            //Login in as role
            User user = this.environment.GetUser(SecurityRole.Investigations);
            new LoginDialog().Login(user.Id, user.Password);

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

            // Select the 'All Investigation Cases' view from the table
            InvestigationCaseSearchPage investigationCaseSearchPage = new InvestigationCaseSearchPage(driver);
            investigationCaseSearchPage.SetPageFilterList("All Investigation Cases");

            Table table = new Table(investigationCaseSearchPage.GetHeaderSearchResultTable());
            Assert.AreEqual(1, table.GetColumnHeaderIndex("Case Number"), "Case Number column is not seen or is not 1st column!!");
            Assert.AreEqual(2, table.GetColumnHeaderIndex("Master Case"), "Master Case column is not seen or is not 2ndt column!!");
            Assert.AreEqual(3, table.GetColumnHeaderIndex("Investigation Status"), "Investigation Status column is not seen or is not 3rd column!!");
            Assert.AreEqual(4, table.GetColumnHeaderIndex("Investigation Sub Status"), "Investigation Sub Status column is not seen or is not 4th column!!");
            Assert.AreEqual(5, table.GetColumnHeaderIndex("Priority"), "Priority column is not seen or is not 5th column!!");
            Assert.AreEqual(6, table.GetColumnHeaderIndex("Received Date"), "Received Date column is not seen or is not 6th column!!");
            Assert.AreEqual(7, table.GetColumnHeaderIndex("Finalised Date"), "Finalised Date column is not seen or is not 7th column!!");
            Assert.AreEqual(8, table.GetColumnHeaderIndex("Duration (days)"), "Duration (days) column is not seen or is not 8th column!!");
            Assert.AreEqual(9, table.GetColumnHeaderIndex("Investigator"), "Investigator column is not seen or is not 9th column!!");
            Assert.AreEqual(10, table.GetColumnHeaderIndex("Owner"), "Owner column is not seen or is not 10th column!!");

            Assert.AreEqual(0, table.GetColumnHeaderIndex("Action Date"), "Action Date column is seen!!");
            Assert.AreEqual(0, table.GetColumnHeaderIndex("Follow Up Date"), "Follow Up Date column is seen!!");
            Assert.AreEqual(0, table.GetColumnHeaderIndex("Title"), "Title column is seen!!");
        }
        public void ATC4431_CRMInvestigationVerifyPhysicalAddressWarningMessage()
        {
            //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.ClickClientsRibbonButton();

            ClientsSearchPage clientsSearchPage = new ClientsSearchPage(driver);
            clientsSearchPage.ClickNewClientButton();

            // Add new client name
            ClientPage clientPage = new ClientPage(driver);
            clientPage.ClickPageTitle();

            // Fill in mandatory fields
            clientPage.SetClientType("Organisation");
            clientPage.SetOrganizationName("TC Investigation");
            clientPage.ClickSaveButton();
            clientPage.ClickPageTitle();

            string clientID = clientPage.GetClientID();

            // Verify that "Physical Address is blank, please select an address." error message is displayed
            Assert.IsTrue(clientPage.VerifyWarningMessagePresent("rta_physicaladdressid"), "Physical Address blank message NOT displayed");
            StringAssert.Contains(clientPage.GetWarningMessage("rta_physicaladdressid"), "Physical Address is blank, please select an address.");

            // Enter valid Physical address
            string BaseWindow = driver.CurrentWindowHandle;

            // Set the postal address
            clientPage.ClickCreateNewClientAddressButton("rta_physicaladdressid");

            driver = UICommon.SwitchToNewBrowserWithTitle(driver, BaseWindow, "Client Address");
            ClientNewAddressPage clientNewAddressPage = new ClientNewAddressPage(driver);
            clientNewAddressPage.SetAddressDetails("Australian Physical", 10, "GRACELAND");

            driver.SwitchTo().Window(BaseWindow);
            clientPage = new ClientPage(driver);

            //Verify Address value
            Assert.AreEqual("10 GRACELAND", clientPage.GetAddressValue("rta_physicaladdressid"));
            Assert.IsFalse(clientPage.VerifyWarningMessagePresent("rta_physicaladdressid"), "Physical Address blank message DISPLAYED!!!!!");
        }
        public void ATC6904c_CRMTopupExcessBondValidation()
        {
            #region Start Up Excel
            MyBook = MyApp.Workbooks.Open(DatasourceDir + @"\TenancyRequests.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() == "Topup_6904")
                {
                    MyRow = i;
                    break;
                }
            }
            #endregion

            string managepingParty = MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("MANAGING_PARTY")].Value.ToString();

            //Login as RBS user
            User user = this.environment.GetUser(SecurityRole.RBSOfficer);
            new LoginDialog().Login(user.Id, user.Password);

            HomePage homePage = new HomePage(driver);
            homePage.HoverCRMRibbonTab();
            homePage.ClickRBSRibbonButton();
            homePage.HoverRBSRibbonTab();
            homePage.ClickRtaTenancyRequestRibbonButton();

            //(Template) - Create new Tenancy Request (Bond Lodgement)
            TenancyRequestsSearchPage tenancyRequestsSearchPage = new TenancyRequestsSearchPage(driver);
            tenancyRequestsSearchPage.ClickNewTenancyRequestButton();

            TenancyRequestPage tenancyRequestPage = new TenancyRequestPage(driver);
            tenancyRequestPage.ClickPageTitle();

            /*Enter details.Details entered
            - Tenancy (prepared Tenancy)
            - Rooming Accommodation
            - Rent subsidy
            - rent $200
            - amount paId $701*/
            tenancyRequestPage.SetRequestTypeListValue(MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("REQUEST_TYPE")].Value.ToString());
            tenancyRequestPage.SetRentalPremisesValue("*"+MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("RENTAL_PREMISES")].Value.ToString());
            tenancyRequestPage.SetManagingPartyListValue(managepingParty);
            tenancyRequestPage.SetTenancyTypeListValue(MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("TENANCY_TYPE")].Value.ToString());
            tenancyRequestPage.SetTenancyManagementTypeListValue(MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("MANAGEMENT_TYPE")].Value.ToString());
            tenancyRequestPage.SetInitialRequestPartyWithSearch(MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("INITIAL_REQUEST_PARTY")].Value.ToString());
            tenancyRequestPage.SetInitialConrtibution("701");
            tenancyRequestPage.SetAmountPaidWithLodgement("701");
            tenancyRequestPage.SetLodgementTypeListValue("Top up");

            tenancyRequestPage.SetWeeklyRent(MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("WEEKLY_RENT")].Value.ToString());
            tenancyRequestPage.SetTenancyStartDate(MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("TENANCY_START")].Value.ToString());
            tenancyRequestPage.SetAnticipatedEndDate(MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("ANTICIPATED_END")].Value.ToString());
            tenancyRequestPage.SetPaymentType(MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("PAYMENT_TYPE")].Value.ToString());
            tenancyRequestPage.SetDwellingTypeListValue(MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("DWELLING_TYPE")].Value.ToString());

            tenancyRequestPage.SetSubsidy("Yes");

            tenancyRequestPage.SetTenancyValue(MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("BOND_REF")].Value.ToString());

            //Save Tenancy Request
            tenancyRequestPage.ClickSaveButton();

            string tenancyrequest = tenancyRequestPage.GetRequestNumber();
            //Update Status Reason to 'Ready for validation'
            tenancyRequestPage.SetStatusReason("Ready for validation");
            tenancyRequestPage.ClickSaveCloseButton();

            tenancyRequestsSearchPage = new TenancyRequestsSearchPage(driver);

            tenancyRequestsSearchPage.SetTenancyRequestSearchText(tenancyrequest);
            Table table = new Table(tenancyRequestsSearchPage.GetSearchResultTable());
            table.ClickCellValue("Name", tenancyrequest, "Name");

            tenancyRequestPage = new TenancyRequestPage(driver);
            tenancyRequestPage.ClickPageTitle();

            //Confirm Status Reason set to 'Validation failed'
            StringAssert.Contains(tenancyRequestPage.GetStatusReason(), "Validation failed");

            //Confirm Queue reason for excess bond added.Status set to 'To be resolved'
            //tenancyRequestPage.ClickQueueReasons();
            Table queueReasonTable = new Table(tenancyRequestPage.GetQueueReasonTable());
            StringAssert.Contains(queueReasonTable.GetCellContainsValue("Reason", "Invalid bond amount : Exceeds maximum bond", "Status Reason"), "To be resolved");

            //Confirm Maximum Allowed Bond set correctly
            //Assert: Maximum Allowed Bond set to $2800
            Assert.AreEqual(tenancyRequestPage.GetMaximumAllowedAmount(), "$800.00");
        }
        public void ATC4448_CRMInvestigationVerifyFilterOnInvestigatorName()
        {
            #region Start Up Excel
            MyBook = MyApp.Workbooks.Open(DatasourceDir + @"\Investigations.xlsx", 0, false, 5, "", "", true, Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
            MySheet = (Excel.Worksheet)MyBook.Sheets[Properties.Settings.Default.ENVIRONMENT.ToString()];
            MyRange = MySheet.UsedRange;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            this.TestSetup();

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            #region Shut down Excel
            MyBook.Save();
            MyBook.Close();
            MyApp.Quit();
            #endregion
        }
        public void ATC6629c_CRMTESTINGEndtoEndSingleFormBPayCRM()
        {
            #region Start Up Excel
            MyApp = new Excel.Application();
            MyApp.Visible = false;
            MyBook = MyApp.Workbooks.Open(DatasourceDir + @"\TenancyRequests.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()== "6629")
                {
                    MyRow = i;
                    break;
                }
            }
            #endregion

            string tenancyrequest = MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("TR_NUMBER")].Value.ToString();
            string bond = MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("BOND_REF")].Value.ToString();

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

            HomePage homePage = new HomePage(driver);
            homePage.HoverCRMRibbonTab();
            homePage.ClickRBSRibbonButton();
            homePage.HoverRBSRibbonTab();
            homePage.ClickRtaTenancyRibbonButton();

            TenancySearchPage tenancySearchPage = new TenancySearchPage(driver);
            tenancySearchPage.SetTenancySearchText(bond);

            Table table = new Table(tenancySearchPage.GetSearchResultTable());
            table.SelectTableRow("Bond Number", bond);

            TenancyPage tenancyPage = new TenancyPage(driver);
            tenancyPage.HoverBondPropertyRibbonTab();
            tenancyPage.ClickBondTenancyRequestRibbonButton();
            tenancyPage.ClickSelectViewButton();
            tenancyPage.SetViewList("All Tenancy Requests");

            table = new Table(tenancyPage.GetSearchResultTable());
            StringAssert.Contains(table.GetCellValue("Name", tenancyrequest, "Name"), tenancyrequest);
            table.ClickCellValue("Name", tenancyrequest, "Name");

            TenancyRequestPage tenancyRequestPage = new TenancyRequestPage(driver);
            tenancyRequestPage.ClickPageTitle();

            StringAssert.Contains(tenancyRequestPage.GetFundedStatus(), "Financials processing successful");
            StringAssert.Contains(tenancyRequestPage.GetPropertyDataControlModeRTAFundedStatus(), "deactivated");
            StringAssert.Contains(tenancyRequestPage.GetAmountMatched(), "$1,000.00");
            StringAssert.Contains(tenancyRequestPage.GetStatusReason(), "Completed");

            //reveiced date?? step 19

            #region Shut down Excel
            MyBook.Save();
            MyBook.Close();
            MyApp.Quit();
            #endregion
        }
        public void ATC6365c_CRMTESTINGEndtoEndSingleFormBPayAXSuccess()
        {
            #region Start Up Excel
            MyBook = MyApp.Workbooks.Open(DatasourceDir + @"\TenancyRequests.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() == "6365")
                {
                    MyRow = i;
                    break;
                }
            }
            #endregion

            string tenancyRequest = MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("TR_NUMBER")].Value.ToString();
            User user = this.environment.GetUser(SecurityRole.RBSOfficer);
            new LoginDialog().Login(user.Id, user.Password);

            HomePage homePage = new HomePage(driver);
            homePage.HoverCRMRibbonTab();
            homePage.ClickRBSRibbonButton();
            homePage.HoverRBSRibbonTab();
            homePage.ClickRtaTenancyRequestRibbonButton();

            TenancyRequestsSearchPage tenancyRequestsSearchPage = new TenancyRequestsSearchPage(driver);
            tenancyRequestsSearchPage.SetPageFilterList("All Tenancy Requests");

            Table table = new Table(tenancyRequestsSearchPage.GetSearchResultTableColHeadings());
            table.ClickTableColumnHeader("Created On");
            table.ClickTableColumnHeader("Created On");

            table = new Table(tenancyRequestsSearchPage.GetSearchResultTable());
            StringAssert.Contains(table.GetCellValue("Name", tenancyRequest, "Status Reason"), "Completed");
            StringAssert.Contains(table.GetCellValue("Name", tenancyRequest, "Processing Status"), "Financials processing successful");

            #region Shut down Excel
            MyBook.Save();
            MyBook.Close();
            MyApp.Quit();
            #endregion
        }
        public void ATC5429_CRMInvestigationVerifyInitialAssessmentQueue()
        {
            User user = this.environment.GetUser(SecurityRole.Investigations);
            new LoginDialog().Login(user.Id, user.Password);

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

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

            // Create new case and validate Status and Substatus fields
            InvestigationCasePage investigationCasePage = new InvestigationCasePage(driver);
            investigationCasePage.ClickSaveButton();
            String caseNumber = investigationCasePage.GetInvestigationCaseNumber();
            String BaseWindow = driver.CurrentWindowHandle;

            // Add the case to Support Officers Queue
            investigationCasePage.ClickAddToQueueButton();
            investigationCasePage.SetQueue("Investigations Initial Assessment");
            investigationCasePage.ClickDialogAddButton();

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

            // Close the current window and login with Investigation Officer
            driver.Close();
            driver = null;

            this.TestSetup();

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

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

            // Verify the "Initial Assessment queue"
            QueueSearchPage investigationQueueSearchPage = new QueueSearchPage(driver);
            investigationQueueSearchPage.SetPageFilterList("All Items");
            investigationQueueSearchPage.SetQueue("Investigations Initial Assessment");  // Need to check with Paul
            Table table = new Table(investigationQueueSearchPage.GetHeaderSearchResultTable());
            table.ClickTableColumnHeader("Entered Queue");
            table.ClickTableColumnHeader("Entered Queue");
            table = new Table(investigationQueueSearchPage.GetSearchResultTable());
            table.GetCellValue("Title", caseNumber, "Title");
        }
        public void ATC5428_CRMInvestigationVerifySupportOfficerQueue()
        {
            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();

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

            // Create new case and validate Status and Substatus fields
            InvestigationCasePage investigationCasePage = new InvestigationCasePage(driver);
            investigationCasePage.ClickSaveButton();
            String caseNumber = investigationCasePage.GetInvestigationCaseNumber();
            String BaseWindow = driver.CurrentWindowHandle;

            // Add the case to Support Officers Queue
            investigationCasePage.ClickAddToQueueButton();
            investigationCasePage.SetQueue("Investigations Support Officers");
            investigationCasePage.ClickDialogAddButton();

            driver = driver.SwitchTo().Window(BaseWindow);
            investigationCasePage.ClickPageTitle();
            investigationCasePage.ClickSaveCloseButton();

            // Verify the Support Officers queue
            driver.SwitchTo().Window(HomeWindow);
            homePage.HoverInvestigationsRibbonTab();
            homePage.ClickInvestigationsQueuesRibbonButton();

            // Verify the "Support Officers queue"
            QueueSearchPage investigationQueueSearchPage = new QueueSearchPage(driver);
            investigationQueueSearchPage.SetSearchRecord(caseNumber);
            investigationQueueSearchPage.SetQueue("Investigations Support Officers");

            Table table = new Table (investigationQueueSearchPage.GetSearchResultTable());
            Assert.AreEqual(1, table.GetRowCount(), "Investigation Case is not added to Support Officers Queue");
        }
        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 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 ATC6837d_CRMCancelBPayRequestBatchWithTopup()
        {
            #region Start Up Excel
            MyBook = MyApp.Workbooks.Open(DatasourceDir + @"\TenancyRequests.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;

            /*Data preparation:
            Request batch is required with the following:

            - Several TRs (Type = Bond Lodgment) under it, including initial lodgement and at least one top-up (i.e. linked to existing Bond Number via {Tenancy} field, must have same managing party / contributors / tenancy address)

            - RB and TR all have {Payment Type} = BPay
            - RB has been successfully validated i.e. RB and TRs have {Status Reason} = Pending financials; are read only (bar bug 6343)
            - RB BPay reference is generated for total amount of all TRs*/

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

            string initialtenancyrequest = MyRange.Cells[tRow1, TenancyRequestSchema.GetColumnIndex("TR_NUMBER")].Value.ToString();

            int tRow2 = 0;
            for (int i = 2; i <= testDataRows; i++)
            {
                if (MyRange.Cells[i, 1].Value.ToString() == "Topup_6837")
                {
                    tRow2 = i;
                    break;
                }
            }
            string topuptenancyrequest = MyRange.Cells[tRow2, TenancyRequestSchema.GetColumnIndex("TR_NUMBER")].Value.ToString();

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

            HomePage homePage = new HomePage(driver);

            homePage.HoverCRMRibbonTab();
            homePage.ClickRBSRibbonButton();
            homePage.HoverRBSRibbonTab();

            homePage.ClickRequestBatchRibbonButton();

            RequestBatchesSearchPage requestBatchSearchPage = new RequestBatchesSearchPage(driver);
            requestBatchSearchPage.ClickNewRequestBatchButton();

            RequestBatchPage requestBatchPage = new RequestBatchPage(driver);
            requestBatchPage.ClickPageTitle();
            requestBatchPage.SetManagingPartyText(MyRange.Cells[tRow1, TenancyRequestSchema.GetColumnIndex("MANAGING_PARTY")].Value.ToString());
            requestBatchPage.SetPaymentType(MyRange.Cells[tRow1, TenancyRequestSchema.GetColumnIndex("PAYMENT_TYPE")].Value.ToString());
            requestBatchPage.ClickSaveButton();
            string requestBatch = requestBatchPage.GetRequestNumber();

            StringAssert.Contains(requestBatch, "TRB-BL-");

            requestBatchPage.ClickAddAssociatedRequestsButton();
            requestBatchPage.SetAssociatedRequest(initialtenancyrequest);

            requestBatchPage.ClickSaveCloseButton();

            requestBatchSearchPage = new RequestBatchesSearchPage(driver);

            requestBatchSearchPage.SetRequestBatchSearchText(requestBatch);
            Table reqBatchTable = new Table(requestBatchSearchPage.GetSearchResultTable());
            reqBatchTable.ClickCellValue("Name", requestBatch, "Name");

            requestBatchPage = new RequestBatchPage(driver);
            requestBatchPage.ClickAddAssociatedRequestsButton();
            requestBatchPage.SetAssociatedRequest(topuptenancyrequest);

            requestBatchPage.ClickSaveButton();
            requestBatchPage.SetStatusReason("Ready for validation");

            requestBatchPage.ClickSaveCloseButton();

            requestBatchSearchPage = new RequestBatchesSearchPage(driver);
            Assert.IsTrue(requestBatchSearchPage.GetPaymentRefernceRefreshTable(requestBatch));
            requestBatchSearchPage.SetRequestBatchSearchText(requestBatch);
            Table requestBatchTable = new Table(requestBatchSearchPage.GetSearchResultTable());
            requestBatchTable.ClickCellValue("Name", requestBatch, "Name");

            requestBatchPage = new RequestBatchPage(driver);
            requestBatchPage.ClickPageTitle();
            Assert.AreEqual(requestBatchPage.GetSumBondamountPaid(), "$2,050.00");

            requestBatchTable = new Table(requestBatchPage.GetPaymentSummaryResultTable());

            StringAssert.Contains(requestBatchTable.GetCellValue("Request Batch", requestBatch, "Request Batch"), requestBatch,"Validate the payment ref record in req batch");
            StringAssert.Contains(requestBatchTable.GetCellValue("Request Batch", requestBatch, "Payment Type"), "BPay","Validate the payment ref record in req batch");
            StringAssert.Contains(requestBatchTable.GetCellValue("Request Batch", requestBatch, "Amount"), "$2,050.00","Validate the payment ref record in req batch");
            StringAssert.Contains(requestBatchTable.GetCellValue("Request Batch", requestBatch, "Client"), MyRange.Cells[tRow1, TenancyRequestSchema.GetColumnIndex("MANAGING_PARTY")].Value.ToString(),"Validate the payment ref record in req batch");

            string reqbatreferencenumber = requestBatchTable.GetCellValue("Request Batch", requestBatch, "Reference Number");

            Thread.Sleep(5000);

            Assert.AreEqual(requestBatchPage.GetStatusReason(), "Pending Financials","Validate the status reason of req batch:"+requestBatch);
            Assert.AreEqual(requestBatchPage.GetFundedStatus(), "Payment pending","Validate the processing status of req batch:"+requestBatch);
            Assert.AreEqual(requestBatchPage.GetRecordStatus(), "Read only","Validate the record status of req bact:"+requestBatch);

            Table tenancyReqTable = new Table(requestBatchPage.GetTenancyRequestTable());
            tenancyReqTable.ClickCellValue("Name", initialtenancyrequest, "Name");

            TenancyRequestPage tenancyReqPage = new TenancyRequestPage(driver);
            tenancyReqPage.ClickPageTitle();
            Assert.AreEqual(tenancyReqPage.GetStatusReason(), "Pending Financials", "Validating the status reason of TR" + initialtenancyrequest);
            Assert.AreEqual(tenancyReqPage.GetRecordStatus(), "Read only","Validating the record status of TR:"+initialtenancyrequest);

            homePage.HoverRBSRibbonTab();
            homePage.ClickRequestBatchRibbonButton();
            requestBatchSearchPage = new RequestBatchesSearchPage(driver);
            requestBatchSearchPage.SetRequestBatchSearchText(requestBatch);
            reqBatchTable = new Table(requestBatchSearchPage.GetSearchResultTable());
            reqBatchTable.ClickCellValue("Name", requestBatch, "Name");

            requestBatchPage = new RequestBatchPage(driver);

            tenancyReqTable = new Table(requestBatchPage.GetTenancyRequestTable());
            tenancyReqTable.ClickCellValue("Name", topuptenancyrequest, "Name");

            tenancyReqPage = new TenancyRequestPage(driver);
            tenancyReqPage.ClickPageTitle();
            Assert.AreEqual(requestBatchPage.GetStatusReason(), "Pending Financials", "Validating the status reason of TR" + topuptenancyrequest);
            Assert.AreEqual(tenancyReqPage.GetRecordStatus(), "Read only","Validating the record status of TR"+topuptenancyrequest);

            //Double-click on the BPay Payment Reference record under the Administration section.
            homePage.HoverRBSRibbonTab();
            homePage.ClickRequestBatchRibbonButton();
            requestBatchSearchPage = new RequestBatchesSearchPage(driver);
            requestBatchSearchPage.SetRequestBatchSearchText(requestBatch);
            reqBatchTable = new Table(requestBatchSearchPage.GetSearchResultTable());
            reqBatchTable.ClickCellValue("Name", requestBatch, "Name");

            requestBatchPage = new RequestBatchPage(driver);
            requestBatchTable = new Table(requestBatchPage.GetPaymentSummaryResultTable());
            IWebElement elem = requestBatchTable.GetCellElementContainsValue("Request Batch", requestBatch, "Reference Number");
            UICommon.DoubleClickElement(elem, driver);

            //Click the [Deactivate] button.Record is deactivated.
            PaymentReferncePage payRefPage = new PaymentReferncePage(driver);
            payRefPage.ClickDeactivateButton();

            WarningDialogueFramePage warnPage = new WarningDialogueFramePage(driver);
            warnPage.ClickProcessBeginButton();
            Thread.Sleep(3000);

            payRefPage = new PaymentReferncePage(driver);
            payRefPage.ClickPageTitle();
            Assert.AreEqual("Inactive", payRefPage.GetInactiveStatusFooter(),"Validate whether payment record of req batch:"+requestBatch+",is inactive after deactivating the record");

            //Inspect Batch Request record.
            homePage.HoverRBSRibbonTab();
            homePage.ClickRequestBatchRibbonButton();
            requestBatchSearchPage = new RequestBatchesSearchPage(driver);
            requestBatchSearchPage.SetRequestBatchSearchText(requestBatch);
            reqBatchTable = new Table(requestBatchSearchPage.GetSearchResultTable());
            reqBatchTable.ClickCellValue("Name", requestBatch, "Name");

            /*Record is active again, editable.
            {Status Reason} = New.
            Processing Status is blank.*/

            requestBatchPage = new RequestBatchPage(driver);
            requestBatchPage.ClickPageTitle();

            Assert.AreEqual(requestBatchPage.GetStatusReason(), "New","Validating the status reason is New for req batch:"+requestBatch);
            Assert.AreEqual(requestBatchPage.GetFundedStatus(), "--","Validating the processing status is blank for req batch:"+requestBatch);

            try
            {
                requestBatchPage.SetPaymentType("BPay");
            }
            catch (Exception)
            {
                new AssertFailedException("Payment Type in Req batch not editable after deactivating the payment ref record:" + requestBatch);
            }

            //Inspect all child Tenancy Request records.
            tenancyReqTable = new Table(requestBatchPage.GetTenancyRequestTable());
            tenancyReqTable.ClickCellValue("Name", initialtenancyrequest, "Name");

            /*Records are active again, editable.
            {Status Reason} = New.
            Processing Status is blank.*/
            tenancyReqPage = new TenancyRequestPage(driver);

            StringAssert.Contains(tenancyReqPage.GetStatusReason(), "New", "Validating the status reason is New for TR" + initialtenancyrequest);
            StringAssert.Contains(tenancyReqPage.GetFundedStatus(), "","Validating the processing status is blank for TR"+initialtenancyrequest);
            try
            {
                tenancyReqPage.SetRequestTypeListValue("Bond Lodgement");
            }
            catch (Exception)
            {
                new AssertFailedException("Request Type in Child Tenacy Req" + initialtenancyrequest + " not editable after deactivating the payment ref record in req batch:" + requestBatch);
            }

            homePage.HoverRBSRibbonTab();
            homePage.ClickRequestBatchRibbonButton();
            requestBatchSearchPage = new RequestBatchesSearchPage(driver);
            requestBatchSearchPage.SetRequestBatchSearchText(requestBatch);

            reqBatchTable = new Table(requestBatchSearchPage.GetSearchResultTable());
            reqBatchTable.ClickCellValue("Name", requestBatch, "Name");

            requestBatchPage = new RequestBatchPage(driver);

            tenancyReqTable = new Table(requestBatchPage.GetTenancyRequestTable());
            tenancyReqTable.ClickCellValue("Name", topuptenancyrequest, "Name");

            tenancyReqPage = new TenancyRequestPage(driver);

            StringAssert.Contains(tenancyReqPage.GetStatusReason(), "New", "Validating the status reason is New for TR:" + topuptenancyrequest);
            StringAssert.Contains(tenancyReqPage.GetFundedStatus(), "","Validating the processing status is blank for TR:" + topuptenancyrequest);
            try
            {
                tenancyReqPage.SetRequestTypeListValue("Bond Lodgement");
            }
            catch (Exception)
            {
                new AssertFailedException("Request Type in Child Tenacy Req" + topuptenancyrequest + " not editable after deactivating the payment ref record in req batch:" + requestBatch);
            }
        }
        public void ATC6622_CRMInvestigationValidateMandatoryTasksForPendingSubStatus()
        {
            //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.SetSubStatus("Case pending");
            investigationCasePage.ClickPageTitle();
            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 = 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", investigationID + ": Set future date", "Activity Status"), "Open");
            Assert.AreEqual( 1, table.GetRowCount() - 1 , "Additional tasks are created for Case pending status");
        }
        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 ATC6629a_CRMTESTINGEndtoEndSingleFormBPayCRM()
        {
            #region Start Up Excel
            MyBook = MyApp.Workbooks.Open(DatasourceDir + @"\TenancyRequests.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()== "6629")
                {
                    MyRow = i;
                    break;
                }

            }
            #endregion

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

            //read excel file and get test data for this test
            // store test data in a class so that it can be used later

            HomePage homePage = new HomePage(driver);
            homePage.HoverCRMRibbonTab();
            homePage.ClickRBSRibbonButton();
            homePage.HoverRBSRibbonTab();
            homePage.ClickRtaTenancyRequestRibbonButton();

            TenancyRequestsSearchPage tenancyRequestsSearchPage = new TenancyRequestsSearchPage(driver);
            tenancyRequestsSearchPage.ClickNewTenancyRequestButton();

            TenancyRequestPage tenancyRequestPage = new TenancyRequestPage(driver);
            tenancyRequestPage.ClickPageTitle();

            tenancyRequestPage.PopulateTenancyRequestValidationSuccessful(
               MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("REQUEST_TYPE")].Value.ToString(),
               MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("RENTAL_PREMISES")].Value.ToString(),
               MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("MANAGING_PARTY")].Value.ToString(),
               MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("TENANCY_TYPE")].Value.ToString(),
               MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("MANAGEMENT_TYPE")].Value.ToString(),
               MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("NO_ROOMS")].Value.ToString(),
               MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("INITIAL_REQUEST_PARTY")].Value.ToString(),
               MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("WEEKLY_RENT")].Value.ToString(),
               MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("INITIAL_CONTRIBUTION")].Value.ToString(),
               MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("AMOUNT_PAID_LODGEMENT")].Value.ToString(),
               MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("LODGEMENT_TYPE")].Value.ToString(),
               MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("TENANCY_START")].Value.ToString(),
               MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("ANTICIPATED_END")].Value.ToString(),
               MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("PAYMENT_TYPE")].Value.ToString());

            tenancyRequestPage.ClickSaveButton();
            string tenancyrequest = tenancyRequestPage.GetRequestNumber();
            StringAssert.Equals(tenancyrequest, "TR-BL-");

            //Add a new request party
            //tenancyRequestPage.ClickRequestPartyAssociated();

            string BaseWindow = driver.CurrentWindowHandle; //Records the current window handle

            tenancyRequestPage.ClickAddNewRequestPartyImage();

            //Enter Request Party details

            driver = tenancyRequestPage.SwitchNewBrowser(driver, BaseWindow);

            TenancyRequestPartyPage tenancyRequestPartyPage = new TenancyRequestPartyPage(driver);
            tenancyRequestPartyPage.SetClientNameValue(
                MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("MISC1")].Value.ToString());
            tenancyRequestPartyPage.SetAmountValue("500.00");
            tenancyRequestPartyPage.ClickSaveCloseButton();

            string amountOtherParty = (MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("INITIAL_CONTRIBUTION")].Value + 500).ToString();
            driver = driver.SwitchTo().Window(BaseWindow);
            tenancyRequestPage = new TenancyRequestPage(driver);
            tenancyRequestPage.SetStatusReason("Ready for validation");
            tenancyRequestPage.ClickSaveButton();
            StringAssert.Contains(tenancyRequestPage.GetValidationStatusReason(), "Validation successful");
            tenancyRequestPage.ClickSaveCloseButton();

            tenancyRequestsSearchPage = new TenancyRequestsSearchPage(driver);
            tenancyRequestsSearchPage.SetTenancyRequestSearchText(tenancyrequest);

            Assert.IsTrue(tenancyRequestsSearchPage.GetPaymentRefernceRefreshTable(tenancyrequest));

            Table table = new Table(tenancyRequestsSearchPage.GetSearchResultTable());
            table.ClickCellValue("Name", tenancyrequest, "Name");

            tenancyRequestPage = new TenancyRequestPage(driver);
            table = new Table(tenancyRequestPage.GetPaymentSummaryResultTable());

            StringAssert.Contains(table.GetCellValue("Tenancy Request", tenancyrequest, "Tenancy Request"), tenancyrequest);
            StringAssert.Contains(table.GetCellValue("Tenancy Request", tenancyrequest, "Request Batch"), "");
            StringAssert.Contains(table.GetCellValue("Tenancy Request", tenancyrequest, "Payment Type"), "BPay");
            StringAssert.Contains(table.GetCellValue("Tenancy Request", tenancyrequest, "Amount"), "$2,000.00");
            StringAssert.Contains(table.GetCellValue("Tenancy Request", tenancyrequest, "Client"), "BLAIR TEST");
            string referencenumber = table.GetCellValue("Tenancy Request", tenancyrequest, "Reference Number");
            StringAssert.Contains(tenancyRequestPage.GetStatusReason(), "Pending Financials");
            StringAssert.Contains(tenancyRequestPage.GetFundedStatus(), "Payment pending");
            string dateValue = DateTime.Today.AddDays(-1).ToString("yyyyMMdd");
            string fileLocation = Utils.BPayFileCreator.bPayFileCreator(referencenumber, dateValue, tenancyrequest, "200000");
            MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("OUTFILE")].Value = fileLocation;
            MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("TR_NUMBER")].Value = tenancyrequest;
            MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("PAY_REF_NUMBER")].Value = referencenumber;
            #region Shut down Excel
            MyBook.Save();
            MyBook.Close();
            MyApp.Quit();
            #endregion
        }
        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 ATC6837c_CRMCancelBPayRequestBatchWithTopup()
        {
            #region Start Up Excel
            MyBook = MyApp.Workbooks.Open(DatasourceDir + @"\TenancyRequests.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 tRow1 = 0;
            for (int i = 2; i <= testDataRows; i++)
            {
                if (MyRange.Cells[i, 1].Value.ToString() == "Topup_6837")
                {
                    tRow1 = i;
                    break;
                }
            }
            #endregion

            string managepingParty = MyRange.Cells[tRow1, TenancyRequestSchema.GetColumnIndex("MANAGING_PARTY")].Value.ToString();
            User user = this.environment.GetUser(SecurityRole.RBSOfficer);
            new LoginDialog().Login(user.Id, user.Password);
            //Creating topup tenancy req for 6837
            HomePage homePage = new HomePage(driver);
            homePage.HoverCRMRibbonTab();
            homePage.ClickRBSRibbonButton();
            homePage.HoverRBSRibbonTab();
            homePage.ClickRtaTenancyRequestRibbonButton();

            TenancyRequestsSearchPage tenancyRequestsSearchPage = new TenancyRequestsSearchPage(driver);
            tenancyRequestsSearchPage.ClickNewTenancyRequestButton();

            TenancyRequestPage tenancyRequestPage = new TenancyRequestPage(driver);
            tenancyRequestPage.ClickPageTitle();
            tenancyRequestPage.PopulateTenancyRequestValidationSuccessful(
                MyRange.Cells[tRow1, TenancyRequestSchema.GetColumnIndex("REQUEST_TYPE")].Value.ToString(),
                MyRange.Cells[tRow1, TenancyRequestSchema.GetColumnIndex("RENTAL_PREMISES")].Value.ToString(),
                managepingParty,
                MyRange.Cells[tRow1, TenancyRequestSchema.GetColumnIndex("TENANCY_TYPE")].Value.ToString(),
                MyRange.Cells[tRow1, TenancyRequestSchema.GetColumnIndex("MANAGEMENT_TYPE")].Value.ToString(),
                MyRange.Cells[tRow1, TenancyRequestSchema.GetColumnIndex("NO_ROOMS")].Value.ToString(),
                MyRange.Cells[tRow1, TenancyRequestSchema.GetColumnIndex("INITIAL_REQUEST_PARTY")].Value.ToString(),
                (MyRange.Cells[tRow1, TenancyRequestSchema.GetColumnIndex("WEEKLY_RENT")].Value + 50).ToString(),
                "25",
                "50",
                "Top up",
                MyRange.Cells[tRow1, TenancyRequestSchema.GetColumnIndex("TENANCY_START")].Value.ToString(),
                MyRange.Cells[tRow1, TenancyRequestSchema.GetColumnIndex("ANTICIPATED_END")].Value.ToString(),
                MyRange.Cells[tRow1, TenancyRequestSchema.GetColumnIndex("PAYMENT_TYPE")].Value.ToString());
            tenancyRequestPage.SetDwellingTypeListValue(MyRange.Cells[tRow1, TenancyRequestSchema.GetColumnIndex("DWELLING_TYPE")].Value.ToString());

            tenancyRequestPage.SetTenancyValue(MyRange.Cells[tRow1 , TenancyRequestSchema.GetColumnIndex("BOND_REF")].Value.ToString());
            tenancyRequestPage.ClickSaveButton();
            string topuptenancyrequest = tenancyRequestPage.GetRequestNumber();
            MyRange.Cells[tRow1, TenancyRequestSchema.GetColumnIndex("TR_NUMBER")].Value = topuptenancyrequest;

            tenancyRequestPage.ClickSaveCloseButton();

            //Creating one initial tenacy request for 6837
            int tRow2 = 0;
            for (int i = 2; i <= testDataRows; i++)
            {
                if (MyRange.Cells[i, 1].Value.ToString() == "Initial_6837")
                {
                    tRow2 = i;
                    break;
                }
            }

            tenancyRequestsSearchPage = new TenancyRequestsSearchPage(driver);
            tenancyRequestsSearchPage.ClickNewTenancyRequestButton();

            tenancyRequestPage = new TenancyRequestPage(driver);
            tenancyRequestPage.ClickPageTitle();

            tenancyRequestPage.PopulateTenancyRequestValidationSuccessful(
                MyRange.Cells[tRow2, TenancyRequestSchema.GetColumnIndex("REQUEST_TYPE")].Value.ToString(),
                MyRange.Cells[tRow2, TenancyRequestSchema.GetColumnIndex("RENTAL_PREMISES")].Value.ToString(),
                managepingParty,
                MyRange.Cells[tRow2, TenancyRequestSchema.GetColumnIndex("TENANCY_TYPE")].Value.ToString(),
                MyRange.Cells[tRow2, TenancyRequestSchema.GetColumnIndex("MANAGEMENT_TYPE")].Value.ToString(),
                MyRange.Cells[tRow2, TenancyRequestSchema.GetColumnIndex("NO_ROOMS")].Value.ToString(),
                MyRange.Cells[tRow2, TenancyRequestSchema.GetColumnIndex("INITIAL_REQUEST_PARTY")].Value.ToString(),
                MyRange.Cells[tRow2, TenancyRequestSchema.GetColumnIndex("WEEKLY_RENT")].Value.ToString(),
                MyRange.Cells[tRow2, TenancyRequestSchema.GetColumnIndex("INITIAL_CONTRIBUTION")].Value.ToString(),
                MyRange.Cells[tRow2, TenancyRequestSchema.GetColumnIndex("AMOUNT_PAID_LODGEMENT")].Value.ToString(),
                MyRange.Cells[tRow2, TenancyRequestSchema.GetColumnIndex("LODGEMENT_TYPE")].Value.ToString(),
                MyRange.Cells[tRow2, TenancyRequestSchema.GetColumnIndex("TENANCY_START")].Value.ToString(),
                MyRange.Cells[tRow2, TenancyRequestSchema.GetColumnIndex("ANTICIPATED_END")].Value.ToString(),
                MyRange.Cells[tRow2, TenancyRequestSchema.GetColumnIndex("PAYMENT_TYPE")].Value.ToString());
            tenancyRequestPage.SetDwellingTypeListValue(MyRange.Cells[tRow2, TenancyRequestSchema.GetColumnIndex("DWELLING_TYPE")].Value.ToString());

            tenancyRequestPage.ClickSaveButton();
            string initialtenancyrequest = tenancyRequestPage.GetRequestNumber();
            tenancyRequestPage.ClickSaveCloseButton();
            MyRange.Cells[tRow2, TenancyRequestSchema.GetColumnIndex("TR_NUMBER")].Value = initialtenancyrequest;
        }
        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 ATC6904a_CRMTopupExcessBondValidation()
        {
            #region Start Up Excel
            MyBook = MyApp.Workbooks.Open(DatasourceDir + @"\TenancyRequests.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() == "Topup_6904")
                {
                    MyRow = i;
                    break;
                }
            }
            #endregion

            //Data preparation step-Tenancy with bond balance of 100

            //Creating a tenancy request for the data prep
            string managepingParty = MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("MANAGING_PARTY")].Value.ToString();

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

            HomePage homePage = new HomePage(driver);
            homePage.HoverCRMRibbonTab();
            homePage.ClickRBSRibbonButton();
            homePage.HoverRBSRibbonTab();
            homePage.ClickRtaTenancyRequestRibbonButton();

            TenancyRequestsSearchPage tenancyRequestsSearchPage = new TenancyRequestsSearchPage(driver);
            tenancyRequestsSearchPage.ClickNewTenancyRequestButton();

            TenancyRequestPage tenancyRequestPage = new TenancyRequestPage(driver);
            tenancyRequestPage.ClickPageTitle();

            tenancyRequestPage.SetRequestTypeListValue(MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("REQUEST_TYPE")].Value.ToString());
            string rentalPremises = MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("RENTAL_PREMISES")].Value.ToString();

            string[] address = rentalPremises.Split(',');

            string roadno = address[0].Split(' ')[0];
            string roadname = address[0].Split(' ')[1];
            string locality = address[1].Split(' ')[1] + "," + address[2] + "," + address[3];

            tenancyRequestPage.CreateNewAddress(roadno,roadname,locality,"Room");
            tenancyRequestPage = new TenancyRequestPage(driver);

            tenancyRequestPage.SetManagingPartyListValue(managepingParty);
            tenancyRequestPage.SetTenancyTypeListValue(MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("TENANCY_TYPE")].Value.ToString());
            tenancyRequestPage.SetTenancyManagementTypeListValue(MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("MANAGEMENT_TYPE")].Value.ToString());
            tenancyRequestPage.SetInitialRequestPartyWithSearch(MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("INITIAL_REQUEST_PARTY")].Value.ToString());
            tenancyRequestPage.SetInitialConrtibution(MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("INITIAL_CONTRIBUTION")].Value.ToString());
            tenancyRequestPage.SetAmountPaidWithLodgement(MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("AMOUNT_PAID_LODGEMENT")].Value.ToString());
            tenancyRequestPage.SetLodgementTypeListValue(MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("LODGEMENT_TYPE")].Value.ToString());

            tenancyRequestPage.SetWeeklyRent(MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("WEEKLY_RENT")].Value.ToString());
            tenancyRequestPage.SetTenancyStartDate(MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("TENANCY_START")].Value.ToString());
            tenancyRequestPage.SetAnticipatedEndDate(MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("ANTICIPATED_END")].Value.ToString());
            tenancyRequestPage.SetPaymentType(MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("PAYMENT_TYPE")].Value.ToString());

            tenancyRequestPage.SetDwellingTypeListValue(MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("DWELLING_TYPE")].Value.ToString());

            tenancyRequestPage.ClickSaveButton();

            string tenancyrequest = tenancyRequestPage.GetRequestNumber();
            MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("TR_NUMBER")].Value = tenancyrequest;
            string amount = MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("INITIAL_CONTRIBUTION")].Value.ToString();
            tenancyRequestPage.SetStatusReason("Ready for validation");
            tenancyRequestPage.ClickSaveButton();
            StringAssert.Contains(tenancyRequestPage.GetValidationStatusReason(), "Validation successful");
            tenancyRequestPage.ClickSaveCloseButton();

            tenancyRequestsSearchPage = new TenancyRequestsSearchPage(driver);
            tenancyRequestsSearchPage.SetTenancyRequestSearchText(tenancyrequest);
            Assert.IsTrue(tenancyRequestsSearchPage.GetPaymentRefernceRefreshTable(tenancyrequest));

            Table table = new Table(tenancyRequestsSearchPage.GetSearchResultTable());
            table.ClickCellValue("Name", tenancyrequest, "Name");

            tenancyRequestPage = new TenancyRequestPage(driver);
            table = new Table(tenancyRequestPage.GetPaymentSummaryResultTable());

            string referencenumber = table.GetCellValue("Tenancy Request", tenancyrequest, "Reference Number");
            MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("PAY_REF_NUMBER")].Value = referencenumber;
            StringAssert.Contains(tenancyRequestPage.GetStatusReason(), "Pending Financials");
            StringAssert.Contains(tenancyRequestPage.GetFundedStatus(), "Payment pending");

            //Create BPay file with new reference number
            string dateValue = DateTime.Today.ToString("yyyyMMdd");
            string fileLocation = Utils.BPayFileCreator.bPayFileCreator(referencenumber, dateValue, tenancyrequest, MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("INITIAL_CONTRIBUTION")].Value.ToString() + "00");
            MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("OUTFILE")].Value = fileLocation;

            #region Shut down Excel
            MyBook.Save();
            MyBook.Close();
            MyApp.Quit();
            #endregion
        }
        public void ATC3309_CRMInvestigationVerifyOfficerCanRecordPhoneCalls()
        {
            #region Start Up Excel
            MyBook = MyApp.Workbooks.Open(DatasourceDir + @"\Investigations.xlsx", 0, false, 5, "", "", true, Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
            MySheet = (Excel.Worksheet)MyBook.Sheets[Properties.Settings.Default.ENVIRONMENT.ToString()];
            MyRange = MySheet.UsedRange;

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

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

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

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

            // Verify that Investigation Officer is able to record Phone call for Investigation Case
            InvestigationCaseSearchPage investigationsCaseSearchPage = new InvestigationCaseSearchPage(driver);
            investigationsCaseSearchPage.ClickNewInvestigationCaseButton();

            // Create new case
            InvestigationCasePage investigationCasePage = new InvestigationCasePage(driver);
            string BaseWindow = driver.CurrentWindowHandle;
            investigationCasePage.ClickSaveButton();
            String investigationID = investigationCasePage.GetInvestigationCaseNumber();

            //Phone Call
            investigationCasePage.ClickPageTitle();
            investigationCasePage.ClickActivitiesAddButton();
            investigationCasePage.ClickAddActivity("Phone Call");
            driver = investigationCasePage.SwitchNewBrowserWithTitle(driver, BaseWindow, "Phone Call");

            PhoneCallPage phoneCall = new PhoneCallPage(driver);
            phoneCall.ClickPageTitle();
            phoneCall.SetSelectSubjectValue("Bond balance enquiry");
            phoneCall.SetSubject("Test 3309 Phone Call");
            phoneCall.SetRecipient(clientName);
            phoneCall.ClickSaveCloseButton();
            driver = driver.SwitchTo().Window(BaseWindow);
            investigationCasePage.CheckForErrors();
            investigationCasePage.ClickPageTitle();
            Table table = new Table(investigationCasePage.GetActivitiesSearchResultTable());
            StringAssert.Contains(table.GetCellContainsValue("Subject", "Test 3309 Phone Call", "Owner"), "IMSTestU03");

            table.ClickCellValue("Subject", "Test 3309 Phone Call", "Subject");
            phoneCall = new PhoneCallPage(driver);
            phoneCall.SwitchFrame();
            StringAssert.Contains(phoneCall.GetSelectSubjectValue(), "Bond balance enquiry");
            StringAssert.Contains(phoneCall.GetSubjectValue(), "Test 3309 Phone Call");
            StringAssert.Contains(phoneCall.GetRecipientValue(), clientName);
            StringAssert.Contains(phoneCall.GetSenderValue(), user.Id);

            // Verify that Investigation Officer is able to record Phone call for Client
            driver = driver.SwitchTo().Window(HomeWindow);
            homePage.HoverCRMRibbonTab();
            homePage.ClickClientServicesRibbonButton();
            homePage.HoverClientServicesRibbonTab();
            homePage.ClickClientsRibbonButton();

            ClientsSearchPage clientsSearchPage = new ClientsSearchPage(driver);
            clientsSearchPage.ClickNewClientButton();

            ClientPage clientPage = new ClientPage(driver);
            BaseWindow = driver.CurrentWindowHandle;
            clientPage.ClickPageTitle();

            clientPage.PopulateNewClient("Client Phone Record");
            clientPage.ClickSaveButton();

            clientPage.ClickActivitiesAddButton();
            clientPage.ClickAddActivity("Phone Call");
            Thread.Sleep(3000);
            driver = clientPage.SwitchNewBrowser(driver, BaseWindow, "Phone Call");

            phoneCall = new PhoneCallPage(driver);

            phoneCall.ClickPageTitle();
            phoneCall.SetSelectSubjectValue("Bond balance enquiry");
            phoneCall.SetSubject("Test 3309 Client Phone Call");

            phoneCall.SetRecipient(clientName);
            phoneCall.ClickSaveCloseButton();
            driver = driver.SwitchTo().Window(BaseWindow);
            phoneCall.CheckForErrors();
            clientPage.ClickPageTitle();
            table = new Table(clientPage.GetActivitiesTable());
            StringAssert.Contains(table.GetCellContainsValue("Subject", "Test 3309 Client Phone Call", "Owner"), "IMSTestU03");

            table.ClickCellValue("Subject", "Test 3309 Client Phone Call", "Subject");
            phoneCall = new PhoneCallPage(driver);
            StringAssert.Contains(phoneCall.GetSelectSubjectValue(), "Bond balance enquiry");
            StringAssert.Contains(phoneCall.GetSubjectValue(), "Test 3309 Client Phone Call");
            StringAssert.Contains(phoneCall.GetRecipientValue(), clientName);
            StringAssert.Contains(phoneCall.GetSenderValue(), user.Id);

            // Verify that Investigation Officer is able to record Phone call for General Case
            homePage.HoverCRMRibbonTab();
            homePage.ClickInvestigationsRibbonButton();
            homePage.HoverInvestigationsRibbonTab();
            homePage.ClickInvestigationsGeneralCasesRibbonButton();

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

            InvestigationGeneralCasePage investigationGeneralCasePage = new InvestigationGeneralCasePage(driver);
            BaseWindow = driver.CurrentWindowHandle;
            investigationGeneralCasePage.ClickPageTitle();
            investigationGeneralCasePage.SetTitle("New General Case");
            investigationGeneralCasePage.SetClientName(clientName);
            investigationGeneralCasePage.SetType("Complaint");
            investigationGeneralCasePage.ClickSaveButton();

            investigationGeneralCasePage.ClickActivitiesAddButton();
            investigationGeneralCasePage.ClickAddActivity("Phone Call");

            driver = investigationGeneralCasePage.SwitchNewBrowserWithTitle(driver, BaseWindow, "Phone Call");

            phoneCall = new PhoneCallPage(driver);

            phoneCall.ClickPageTitle();
            phoneCall.SetSelectSubjectValue("Bond balance enquiry");
            phoneCall.SetSubject("Test 3309 General Case Phone Call");

            phoneCall.SetRecipient(clientName);
            phoneCall.ClickSaveCloseButton();
            driver = driver.SwitchTo().Window(BaseWindow);
            phoneCall.CheckForErrors();
            investigationGeneralCasePage.ClickPageTitle();

             table = new Table(investigationGeneralCasePage.GetActivitiesTable());
            StringAssert.Contains(table.GetCellContainsValue("Subject", "Test 3309 General Case Phone Call", "Owner"), "IMSTestU03");

            table.ClickCellValue("Subject", "Test 3309 General Case Phone Call", "Subject");
            phoneCall = new PhoneCallPage(driver);
            StringAssert.Contains(phoneCall.GetSelectSubjectValue(), "Bond balance enquiry");
            StringAssert.Contains(phoneCall.GetSubjectValue(), "Test 3309 General Case Phone Call");
            StringAssert.Contains(phoneCall.GetRecipientValue(), clientName);
            StringAssert.Contains(phoneCall.GetSenderValue(), user.Id);

            #region Shut down Excel
            MyBook.Save();
            MyBook.Close();
            MyApp.Quit();
            #endregion
        }
        public void ATC7120a_CRMAC1Fileformatverification()
        {
            #region Start Up Excel
            MyBook = MyApp.Workbooks.Open(DatasourceDir + @"\TenancyRequests.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()== "7120")
                {
                    MyRow = i;
                    break;
                }
            }
            #endregion

            string managepingParty = MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("MANAGING_PARTY")].Value.ToString();
            string amountPaidLodgement = MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("AMOUNT_PAID_LODGEMENT")].Value.ToString();

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

            HomePage homePage = new HomePage(driver);
            homePage.HoverCRMRibbonTab();
            homePage.ClickRBSRibbonButton();
            homePage.HoverRBSRibbonTab();
            homePage.ClickRtaTenancyRequestRibbonButton();

            TenancyRequestsSearchPage tenancyRequestsSearchPage = new TenancyRequestsSearchPage(driver);
            tenancyRequestsSearchPage.ClickNewTenancyRequestButton();

            TenancyRequestPage tenancyRequestPage = new TenancyRequestPage(driver);
            tenancyRequestPage.ClickPageTitle();

            tenancyRequestPage.PopulateTenancyRequestValidationSuccessful(
                MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("REQUEST_TYPE")].Value.ToString(),
                MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("RENTAL_PREMISES")].Value.ToString(),
                managepingParty,
                MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("TENANCY_TYPE")].Value.ToString(),
                MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("MANAGEMENT_TYPE")].Value.ToString(),
                MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("NO_ROOMS")].Value.ToString(),
                MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("INITIAL_REQUEST_PARTY")].Value.ToString(),
                MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("WEEKLY_RENT")].Value.ToString(),
                MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("INITIAL_CONTRIBUTION")].Value.ToString(),
                amountPaidLodgement,
                MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("LODGEMENT_TYPE")].Value.ToString(),
                MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("TENANCY_START")].Value.ToString(),
                MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("ANTICIPATED_END")].Value.ToString(),
                MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("PAYMENT_TYPE")].Value.ToString());

            tenancyRequestPage.ClickSaveButton();
            string tenancyrequest;
            tenancyrequest = tenancyRequestPage.GetRequestNumber();
            StringAssert.Equals(tenancyrequest, "TR-BL-");
            MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("TR_NUMBER")].Value = tenancyrequest;

            tenancyRequestPage.SetStatusReason("Ready for validation");
            tenancyRequestPage.ClickSaveButton();
            StringAssert.Contains(tenancyRequestPage.GetValidationStatusReason(), "Validation successful");
            tenancyRequestPage.ClickSaveCloseButton();

            tenancyRequestsSearchPage = new TenancyRequestsSearchPage(driver);
            tenancyRequestsSearchPage.SetTenancyRequestSearchText(tenancyrequest);
            Table table = new Table(tenancyRequestsSearchPage.GetSearchResultTable());
            table.ClickCellValue("Name", tenancyrequest, "Name");
            tenancyRequestPage = new TenancyRequestPage(driver);
            tenancyRequestPage.ClickPageTitle();
            StringAssert.Contains(tenancyRequestPage.GetStatusReason(), "Pending Financials");
            StringAssert.Contains(tenancyRequestPage.GetFundedStatus(), "Payment pending");
            table = new Table(tenancyRequestPage.GetPaymentSummaryResultTable());
            StringAssert.Contains(table.GetCellValue("Tenancy Request", tenancyrequest, "Tenancy Request"), tenancyrequest);
            StringAssert.Contains(table.GetCellValue("Tenancy Request", tenancyrequest, "Payment Type"), "BPay");
            StringAssert.Contains(table.GetCellValue("Tenancy Request", tenancyrequest, "Amount"),
                ((double)Int32.Parse(amountPaidLodgement)).ToString("C"));
            StringAssert.Contains(table.GetCellValue("Tenancy Request", tenancyrequest, "Client"), managepingParty);
            string referencenumber = table.GetCellValue("Tenancy Request", tenancyrequest, "Reference Number");
            MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("PAY_REF_NUMBER")].Value = referencenumber;

            //Create BPay file with new reference number
            string dateValue = DateTime.Today.ToString("yyyyMMdd");
            string fileLocation = Utils.BPayFileCreator.bPayFileCreator(referencenumber, dateValue, tenancyrequest, MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("INITIAL_CONTRIBUTION")].Value.ToString() + "00");
            MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("OUTFILE")].Value = fileLocation;

            #region Shut down Excel
            MyBook.Save();
            MyBook.Close();
            MyApp.Quit();
            #endregion
        }
        public void ATC3284_CRMEntityAllegedOffenceBeliefDateblankedStatusReasonreverts()
        {
            string allegedoffenceId;
            string todayDate = DateTime.Now.ToString("d/MM/yyyy");
            string investigationID;

            //Login in as role
            User user = this.environment.GetUser(SecurityRole.Investigations);
            new LoginDialog().Login(user.Id, user.Password);

            HomePage homePageInvestigation = new HomePage(driver);
            homePageInvestigation.HoverCRMRibbonTab();
            homePageInvestigation.ClickInvestigationsRibbonButton();
            homePageInvestigation.HoverInvestigationsRibbonTab();
            homePageInvestigation.ClickInvestigationsCasesRibbonButton();

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

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

            homePageInvestigation.HoverCRMRibbonTab();
            homePageInvestigation.ClickInvestigationsRibbonButton();
            homePageInvestigation.HoverInvestigationsRibbonTab();
            homePageInvestigation.ClickRightScrollRibbonButton();
            homePageInvestigation.ClickAllegedOffencesButton();

            AllegendOffensesSearchPage allegedOffencesSearchPage = new AllegendOffensesSearchPage(driver);

            allegedOffencesSearchPage.ClickNewAllegedOffenceButton();

            AllegedOffencePage allegedOffencesPage = new AllegedOffencePage(driver);
            allegedOffencesPage.SetInvestigationCaseValue(investigationID);
            allegedOffencesPage.SetProvisionValue("RTRA 116(1)");
            allegedOffencesPage.SetOffenceDateValue("1/01/2015");
            allegedOffencesPage.SetBeliefFormedDateValue(todayDate);
            allegedOffencesPage.ClickSaveButton();
            allegedoffenceId = allegedOffencesPage.GetReferenceNumber();
            allegedOffencesPage.ClickSaveCloseButton();

            allegedOffencesSearchPage = new AllegendOffensesSearchPage(driver);
            allegedOffencesSearchPage.SetInvestigationSearchText(investigationID);
            Table table = new Table(allegedOffencesSearchPage.GetSearchResultTable());
            table.SelectTableRow("Status Reason", "Belief");

            allegedOffencesPage = new AllegedOffencePage(driver);
            allegedOffencesPage.SetOffenceDateValue("");
            StringAssert.Contains(allegedOffencesPage.GetOffenceDateValue(),"--");
            allegedOffencesPage.SetBeliefFormedDateValue("");
            StringAssert.Contains(allegedOffencesPage.GetStatusReason(), "Suspicion");

            allegedoffenceId = allegedOffencesPage.GetReferenceNumber();
            allegedOffencesPage.ClickSaveCloseButton();

            allegedOffencesSearchPage = new AllegendOffensesSearchPage(driver);
            allegedOffencesSearchPage.SetInvestigationSearchText(allegedoffenceId);
            table = new Table(allegedOffencesSearchPage.GetSearchResultTable());
            table.SelectContainsTableRow("Investigation Case", investigationID);

            allegedOffencesPage = new AllegedOffencePage(driver);
            StringAssert.Contains(allegedOffencesPage.GetStatusReason(), "Suspicion");
            StringAssert.Contains(allegedOffencesPage.GetOffenceDateValue(), "--");
            StringAssert.Contains(allegedOffencesPage.GetStatutoryLimitationValue(), "--");

            allegedOffencesPage.SetOffenceDateValue("01/01/2015");
            allegedOffencesPage.ClickSaveButton();

            StringAssert.Contains(allegedOffencesPage.GetStatutoryLimitationValue(), "1/01/2016");

            StringAssert.Contains(allegedOffencesPage.GetBefliefFormedDateValue(),"");
        }