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 bool GetPaymentRefernceRefreshTable(string tenancyrequest)
        {
            int i = 1;
            while (i <= 60) //waits for 60sec
            {
                Table table = new Table(this.GetSearchResultTable());
                if (table.GetCellValue("Name", tenancyrequest, "Status Reason") == "Pending Financials")
                {
                    return true;

                }else
                {
                    Thread.Sleep(1000);
                    WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(waitsec));
                    wait.Until(ExpectedConditions.ElementIsVisible(By.Id("grid_refresh"))).Click();
                    i++;
                }

            } throw new Exception(String.Format("Status Reason has not changed to Pending Financials"));
        }
        public void ATC3351_CRMEntityClientNameCreateNewWithInformation()
        {
            #region Start Up Excel
            MyBook = MyApp.Workbooks.Open(DatasourceDir + @"\Clients.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, ClientsSchema.GetColumnIndex("CLIENT_NAME")].Value.ToString());
            string EmailID = (MyRange.Cells[MyRow, ClientsSchema.GetColumnIndex("EMAIL")].Value.ToString());

            //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.ClickClientServicesRibbonButton();
            homePage.HoverClientServicesRibbonTab();
            homePage.ClickClientsRibbonButton();

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

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

            // Fill in mandatory fields
            clientPage.PopulateNewClient(clientName);

            // Fill in Email address
            clientPage.SetEmail1ID(EmailID);
            clientPage.ClickSaveButton();
            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"));

            // Navigate to client phone numbers
            driver.SwitchTo().Window(HomeWindow);
            homePage.HoverClientXRibbonTab(clientName);
            homePage.ClickClientXPhoneNumbersRibbonButton();
            clientPage = new ClientPage(driver);
            BaseWindow = driver.CurrentWindowHandle;

            clientPage.ClickAddNewClientPhoneImage();

            driver = UICommon.SwitchToNewBrowserWithTitle(driver, BaseWindow, "Client Phone Number");

            ClientPhoneNumberPage clientPhoneNumberPage = new ClientPhoneNumberPage(driver);
            //clientPhoneNumberPage.ClickTypeList();
            clientPhoneNumberPage.SetTypeListValue("Fixed Line");
            //clientPhoneNumberPage.ClickAreaCodeElement();
            clientPhoneNumberPage.SetAreaCodeValue("07");
            //clientPhoneNumberPage.ClickPhoneNumberElement();
            clientPhoneNumberPage.SetPhoneNumberValue("11111111");
            clientPhoneNumberPage.ClickSaveCloseButton();

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

            clientPage.SetClientSearchText(clientName);
            Table table = new Table(clientPage.GetSearchResultTable());

            StringAssert.Contains(table.GetCellValue("Client", clientName, "Full Phone Number"), "+61 7 1111 1111");

            #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 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 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 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 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 ATC6780_CRMNewTenancyRequestTestResidentialTenancyTest()
        {
            #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() == "6780")
                {
                    MyRow = i;
                    break;
                }
            }
            #endregion

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

            //Attemp to save with NO Mandatory data
            tenancyRequestPage.SetRequestTypeListValue("Bond Lodgement");
            tenancyRequestPage.ClickSaveButton();
            //StringAssert.StartsWith(tenancyRequestPage.GetRentalPremiseAddressErrorText(), "You must provide a value for Rental Premises.");

            //Attempt to Enter Invalid Bedroom values
            tenancyRequestPage.SetNumberOfBedrooms("0");
            StringAssert.Contains(tenancyRequestPage.GetAlertMessage(), "You must enter a whole number between 1 and 12.");
            StringAssert.Contains(tenancyRequestPage.GetAlertMessage(), "You must enter a whole number between 1 and 12.");

            //Attempt to Enter Invalid Bedoom values
            tenancyRequestPage.SetNumberOfBedrooms("13");
            StringAssert.Contains(tenancyRequestPage.GetAlertMessage(), "You must enter a whole number between 1 and 12.");
            StringAssert.Contains(tenancyRequestPage.GetAlertMessage(), "You must enter a whole number between 1 and 12.");

            //Attempt to Enter Invalid Bedroom values
            tenancyRequestPage.SetNumberOfBedrooms("1");
            //StringAssert.Contains(tenancyRequestPage.GetRTAValidationMessage(), "You must");  This needs a ! contrains

            //Attemp to save with Mandatory data
            // tenancyRequestPage.PopulateTenancyRequestFormResidentialTenancy("1 THOMAS ST, BIRKDALE, QLD, 4159", "Residential Tenancy", "AMANDA TEST", "3", "AARON BALL", "700", "700", "Initial");
            tenancyRequestPage.PopulateTenancyRequestFormResidentialTenancy(
               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("INITIAL_CONTRIBUTION")].Value.ToString(),
               MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("AMOUNT_PAID_LODGEMENT")].Value.ToString(),
               MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("LODGEMENT_TYPE")].Value.ToString());

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

            //Assert the warning message regarding Tenancy Start Date and Total Contribution amount
            warningMessage = tenancyRequestPage.GetWarningMessage();
            StringAssert.Contains(warningMessage, "Tenancy Start is blank, please select a date.");

            //Fill in start date and check that warning message is removed
            //tenancyRequestPage.ClickTenancyStartDate();
            tenancyRequestPage.SetTenancyStartDate("01/03/2015");
            tenancyRequestPage.ClickSaveButton();
            //StringAssert.Contains(tenancyRequestPage.GetWarningMessage(),"Tenancy Start is blank, please select a date.");

            //Assert that Date Bond Received at RTA is read only
            controlMode = tenancyRequestPage.GetPropertyDataControlModeRTADateReceivedAtRTA();
            StringAssert.Equals(controlMode, "locked");

            //Assert that Funded Status is read only
            controlMode = tenancyRequestPage.GetPropertyDataControlModeRTAFundedStatus();
            StringAssert.Equals(controlMode, "locked");

            String tenancyNumber = tenancyRequestPage.GetRequestNumber();
            StringAssert.StartsWith(tenancyNumber, "TR-BL-");

            //Assert that saved record can be found in the record grid
            tenancyRequestPage.ClickSaveCloseButton();

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

            Table table = new Table(tenancyRequestsSearchPage.GetSearchResultTable());

            //Assert that the status reason can be confirmed on the table
            StringAssert.Equals(table.GetCellValue("Name", tenancyNumber, "Status Reason"), "New");

            //Assert that a value in a particular column in a table exists
            StringAssert.Equals(table.GetCellContainsValue("Name", tenancyNumber, "Amount Bond Paid with Lodgement"),
                MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("INITIAL_CONTRIBUTION")].Value.ToString());

            ////Assert that a search result record can be opened
            table.ClickCellValue("Name", tenancyNumber, "Name");
            tenancyRequestPage = new TenancyRequestPage(driver);
            StringAssert.Equals(tenancyRequestPage.GetRequestNumber(), tenancyNumber);

            #region Shut down Excel
            MyBook.Save();
            MyBook.Close();
            MyApp.Quit();
            #endregion
        }
        public void ATC4399_CRMDisplaydwellingtype()
        {
            #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() == "4399")
                {
                    MyRow = i;
                    break;
                }
            }
            #endregion

            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 tenancyRequestSearchPage = new TenancyRequestsSearchPage(driver);
            tenancyRequestSearchPage.ClickNewTenancyRequestButton();

            TenancyRequestPage tenancyRequestPage = new TenancyRequestPage(driver);
            tenancyRequestPage.ClickPageTitle();
            //tenancyRequestPage.PopulateTenancyRequestFormResidentialTenancy("1 THOMAS ST, BIRKDALE, QLD, 4159", "Residential Tenancy", "AMANDA TEST", "3", "AARON BALL", "700", "700", "Initial");
            tenancyRequestPage.PopulateTenancyRequestFormResidentialTenancy(
               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("INITIAL_CONTRIBUTION")].Value.ToString(),
               MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("AMOUNT_PAID_LODGEMENT")].Value.ToString(),
               MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("LODGEMENT_TYPE")].Value.ToString());

            //tenancyRequestPage.ClickSaveButton();

            ////Assert Dwelling Type field

            Assert.IsTrue(tenancyRequestPage.GetDwellingTypeText("Flat/Unit"));
            tenancyRequestPage.ClickPageTitle();
            Assert.IsTrue(tenancyRequestPage.GetDwellingTypeText("House"));
            tenancyRequestPage.ClickPageTitle();
            Assert.IsTrue(tenancyRequestPage.GetDwellingTypeText("Townhouse/Semi-Detached House"));
            tenancyRequestPage.ClickPageTitle();
            Assert.IsTrue(tenancyRequestPage.GetDwellingTypeText("Student Accommodation on Campus"));
            tenancyRequestPage.ClickPageTitle();
            Assert.IsTrue(tenancyRequestPage.GetDwellingTypeText("Moveable Dwelling/Site"));
            tenancyRequestPage.ClickPageTitle();
            Assert.IsTrue(tenancyRequestPage.GetDwellingTypeText("Moveable Dwelling/Site with electricity supplied and individually metered"));
            tenancyRequestPage.ClickPageTitle();
            Assert.IsTrue(tenancyRequestPage.GetDwellingTypeText("Studio"));

            ////Change Tenancy type
            //tenancyRequestPage.ClickTenancyTypeList();
            tenancyRequestPage.SetResidentialTenancyTypeList("Rooming Accommodation");
            tenancyRequestPage.SetResidentialManagementTypeList("Lessor/Owner");
            ////Assert Dwelling Type field
            Assert.IsTrue(tenancyRequestPage.GetDwellingTypeText("Boarding House"));
            tenancyRequestPage.ClickPageTitle();
            Assert.IsTrue(tenancyRequestPage.GetDwellingTypeText("Supported Accommodation"));
            tenancyRequestPage.ClickPageTitle();
            Assert.IsTrue(tenancyRequestPage.GetDwellingTypeText("Student Accommodation off Campus"));
            tenancyRequestPage.ClickPageTitle();
            Assert.IsTrue(tenancyRequestPage.GetDwellingTypeText("Studio"));

            //Assert Save Successful
            tenancyRequestPage.ClickSaveButton();
            StringAssert.Contains(tenancyRequestPage.GetRequestNumber(), "TR-BL-");

            string tenancyRequest = tenancyRequestPage.GetRequestNumber();
            tenancyRequestPage.ClickSaveCloseButton();

            //Assert record in search table
            tenancyRequestSearchPage = new TenancyRequestsSearchPage(driver);
            tenancyRequestSearchPage.SetTenancyRequestSearchText(tenancyRequest);
            Table table = new Table(tenancyRequestSearchPage.GetSearchResultTable());
            StringAssert.Contains(table.GetCellValue("Name", tenancyRequest, "Tenancy Type"), "Rooming Accommodation");

            //Change Dwelling and check search table again
            table.ClickCellValue("Name", tenancyRequest, "Name");
            tenancyRequestPage = new TenancyRequestPage(driver);

            //tenancyRequestPage.ClickTenancyTypeList();
            tenancyRequestPage.SetResidentialTenancyTypeList("Residential Tenancy");
            tenancyRequestPage.SetResidentialManagementTypeList("Lessor/Owner");
            tenancyRequestPage.ClickSaveCloseButton();

            //Assert record in search table
            tenancyRequestSearchPage = new TenancyRequestsSearchPage(driver);
            tenancyRequestSearchPage.SetTenancyRequestSearchText(tenancyRequest);
            table = new Table(tenancyRequestSearchPage.GetSearchResultTable());
            StringAssert.Contains(table.GetCellValue("Name", tenancyRequest, "Tenancy Type"), "Residential Tenancy");

            #region Shut down Excel
            MyBook.Save();
            MyBook.Close();
            MyApp.Quit();
            #endregion
        }
        public void ATC6751a_CRMBTriggerUpdateToCheque()
        {
            #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() == "6751")
                {
                    MyRow = i;
                    break;
                }
            }
            #endregion

            string managingParty = MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("MANAGING_PARTY")].Value.ToString();
            string initialRequestParty = MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("INITIAL_REQUEST_PARTY")].Value.ToString();
            string amountOtherParty = (MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("INITIAL_CONTRIBUTION")].Value +
               MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("MISC2")].Value).ToString();

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

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

            TenancyRequestsSearchPage tenancyRequestSearchPage = new TenancyRequestsSearchPage(driver);
            tenancyRequestSearchPage.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(),
                managingParty,
                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 = new TenancyRequestPage(driver);
            tenancyRequestPage.SetDwellingTypeListValue("House");

            tenancyRequestPage.ClickSaveButton();

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

            //Reopen the record and change the status reason to Ready for Validation and save.The record should show an exception with Invalid Keyword
            tenancyRequestSearchPage = new TenancyRequestsSearchPage(driver);
            tenancyRequestSearchPage.SetTenancyRequestSearchText(tenancyRequest);
            Table table = new Table(tenancyRequestSearchPage.GetSearchResultTable());
            table.ClickCellValue("Name", tenancyRequest, "Name");

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

            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 EFT file with new reference number
            MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("OUTFILE")].Value = Utils.BAI2FileCreator.bAI2FileCreator(referencenumber, amountOtherParty);

            #region Shut down Excel
            MyBook.Save();
            MyBook.Close();
            MyApp.Quit();
            #endregion
        }
        public void ATC6708_CRMDistributeAmountForContributors()
        {
            #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() == "6708")
                {
                    MyRow = i;
                    break;
                }
            }
            #endregion

            string secondContributor = MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("MISC1")].Value.ToString();
            string thridContributor = MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("MISC2")].Value.ToString();

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

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

            //Create new Tenancy Request with mandatory fields populated
            TenancyRequestsSearchPage tenancyRequestSearchPage = new TenancyRequestsSearchPage(driver);

            tenancyRequestSearchPage.ClickNewTenancyRequestButton();

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

            string initialRequestParty = MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("INITIAL_REQUEST_PARTY")].Value.ToString();
            string initialContribution = MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("INITIAL_CONTRIBUTION")].Value.ToString();

             tenancyRequestPage.PopulateMandatoryFieldValues(
              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(),
              initialRequestParty,
              MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("WEEKLY_RENT")].Value.ToString(),
              initialContribution,
              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());

            //Save Tenancy Record
            tenancyRequestPage.ClickSaveButton();
            string tenancyRequest = tenancyRequestPage.GetRequestNumber();

            //Inspect Screen for Warnings "Warning displays that {Amount Paid with Lodgement} field <> sum of contributors."
            string warningMessage = tenancyRequestPage.GetWarningMessage();
            StringAssert.Contains(warningMessage, "Sum of Request does not equal the amount entered for Amount Paid with Lodgement","Validating the warning appears");

            //Click the ribbon button Distribute and Save the record. Warnings should disappear
            string alertMessage = tenancyRequestPage.ClickDistributeButton();
            StringAssert.Contains(alertMessage, "Distribution process has been initiated");

            //TODO:This is an issue an extra save dialog pops up and clicking OK button on this.
            string saveMessage = tenancyRequestPage.GetAlertMessage();
            StringAssert.Contains(saveMessage, "Your changes have not been saved");

            warningMessage = tenancyRequestPage.GetWarningMessage();
            Assert.AreEqual(warningMessage, "","Validating that warning message disappeared");

            //Add another contributor and populate amount field with > $1. Save Record. Warning should appear.
            string BaseWindow = driver.CurrentWindowHandle; //Records the current window handle
            tenancyRequestPage.ClickAddNewRequestPartyImage();
            Thread.Sleep(2000);

            driver = tenancyRequestPage.SwitchNewBrowser(driver, BaseWindow);

            TenancyRequestPartyPage tenancyRequestPartyPage = new TenancyRequestPartyPage(driver);
            tenancyRequestPartyPage.ClickPageTitle();
            tenancyRequestPartyPage.SetClientNameValue(secondContributor);
            tenancyRequestPartyPage.SetAmountValue("100");
            tenancyRequestPartyPage.ClickSaveCloseButton();

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

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

            tenancyRequestPage.ClickSaveButton();

               //TODO:Issue the waning does not appear without refreshing the record.This is a workaround.
            homePage.HoverCRMRibbonTab();
            homePage.ClickRBSRibbonButton();
            homePage.HoverRBSRibbonTab();
            homePage.ClickRtaTenancyRequestRibbonButton();

            tenancyRequestSearchPage = new TenancyRequestsSearchPage(driver);
            tenancyRequestSearchPage.SetTenancyRequestSearchText(tenancyRequest);
            Table table = new Table(tenancyRequestSearchPage.GetSearchResultTable());
            StringAssert.Contains(table.GetCellValue("Name", tenancyRequest, "Status Reason"), "New");

            table.ClickCellValue("Name", tenancyRequest, "Name");

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

            //Inspect warning appears
            warningMessage = tenancyRequestPage.GetWarningMessage();
            StringAssert.Contains(warningMessage, "Sum of Request does not equal the amount entered for Amount Paid with Lodgement","Validating that the warning appears");

            //Add another contributor and populate amount field with > $1. Save Record. Warning should appear.
            BaseWindow = driver.CurrentWindowHandle; //Records the current window handle
            tenancyRequestPage.ClickAddNewRequestPartyImage();
            Thread.Sleep(2000);
            driver = tenancyRequestPage.SwitchNewBrowser(driver, BaseWindow);

            tenancyRequestPartyPage = new TenancyRequestPartyPage(driver);
            tenancyRequestPartyPage.ClickPageTitle();
            tenancyRequestPartyPage.SetClientNameValue(thridContributor);
            tenancyRequestPartyPage.SetAmountValue("100");
            tenancyRequestPartyPage.ClickSaveCloseButton();

            driver = driver.SwitchTo().Window(BaseWindow);
            tenancyRequestPage = new TenancyRequestPage(driver);
            tenancyRequestPage.ClickPageTitle();

            tenancyRequestPage.ClickSaveButton();

            //Inspect warning appears
            warningMessage = tenancyRequestPage.GetWarningMessage();
            StringAssert.Contains(warningMessage, "Sum of Request does not equal the amount entered for Amount Paid with Lodgement","Validating that the warning appears");

            //Click the ribbon button Distribute and Save the record. Warning should disappear.
            alertMessage = tenancyRequestPage.ClickDistributeButton();
            StringAssert.Contains(alertMessage, "Distribution process has been initiated");

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

            //Issue the waning does disappear not appear without refreshing the record.This is a workaround.
            homePage.HoverCRMRibbonTab();
            homePage.ClickRBSRibbonButton();
            homePage.HoverRBSRibbonTab();
            homePage.ClickRtaTenancyRequestRibbonButton();

            tenancyRequestSearchPage = new TenancyRequestsSearchPage(driver);
            tenancyRequestSearchPage.SetTenancyRequestSearchText(tenancyRequest);
            table = new Table(tenancyRequestSearchPage.GetSearchResultTable());
            StringAssert.Contains(table.GetCellValue("Name", tenancyRequest, "Status Reason"), "New");

            table.ClickCellValue("Name", tenancyRequest, "Name");

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

            //Warning disappears
            warningMessage = tenancyRequestPage.GetWarningMessage();
            Assert.AreEqual(warningMessage, "", "Validating that warning message disappeared");

            //Modify amount paid with lodgemnt to $1500 and inspect warning appears
            tenancyRequestPage.SetAmountPaidWithLodgement("1500");
            tenancyRequestPage.ClickSaveButton();

            warningMessage = tenancyRequestPage.GetWarningMessage();
            StringAssert.Contains(warningMessage, "Sum of Request does not equal the amount entered for Amount Paid with Lodgement","Validating that the warning appears");

            //TODO:Modify Contibutor amount to be different but still adds up to amount. Inspect warning disappears
            Table requestPartyTable = new Table(tenancyRequestPage.GetRequestPartyTable());
            StringAssert.Contains(requestPartyTable.GetCellContainsValue("Client", secondContributor, "Request Amount"), "400");

            BaseWindow = driver.CurrentWindowHandle;
            UICommon.DoubleClickElement(requestPartyTable.GetCellElementContainsValue("Client", secondContributor, "Client"), driver);
            Thread.Sleep(1000);

            driver = tenancyRequestPage.SwitchNewBrowser(driver, BaseWindow);

            tenancyRequestPartyPage = new TenancyRequestPartyPage(driver);
            tenancyRequestPartyPage.ClickPageTitle();

            tenancyRequestPartyPage.SetAmountValue("700");
            tenancyRequestPage.ClickSaveCloseButton();

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

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

            tenancyRequestPage.ClickSaveButton();

            //TODO.WArnings does not disappear without refreshing the record. This is a workaround.
            homePage.HoverCRMRibbonTab();
            homePage.ClickRBSRibbonButton();
            homePage.HoverRBSRibbonTab();
            homePage.ClickRtaTenancyRequestRibbonButton();

            tenancyRequestSearchPage = new TenancyRequestsSearchPage(driver);
            tenancyRequestSearchPage.SetTenancyRequestSearchText(tenancyRequest);
            table = new Table(tenancyRequestSearchPage.GetSearchResultTable());
            StringAssert.Contains(table.GetCellValue("Name", tenancyRequest, "Status Reason"), "New");

            table.ClickCellValue("Name", tenancyRequest, "Name");

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

            //Warning disappears
            warningMessage = tenancyRequestPage.GetWarningMessage();
            Assert.AreEqual(warningMessage, "", "Validating that warning message disappeared");

            //Modify amount paid with lodgement to be $900
            tenancyRequestPage.SetAmountPaidWithLodgement("900");
            tenancyRequestPage.ClickSaveButton();

            //Warning appears
            warningMessage = tenancyRequestPage.GetWarningMessage();
            StringAssert.Contains(warningMessage, "Sum of Request does not equal the amount entered for Amount Paid with Lodgement","Validating that the warning appesrs");

            //Click Distribute and save the record. Warning should disappear
            tenancyRequestPage.ClickDistributeButton();
            tenancyRequestPage.ClickSaveButton();

            warningMessage = tenancyRequestPage.GetWarningMessage();
            Assert.AreEqual(warningMessage, "", "Validating that warning message disappeared");

            #region Shut down Excel
            MyBook.Save();
            MyBook.Close();
            MyApp.Quit();
            #endregion
        }
        public void ATC6362a_E2ESingleBPAYCancelTenancyRequest()
        {
            #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() == "6362")
                {
                    MyRow = i;
                    break;
                }
            }
            #endregion

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

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

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

            /*Data prep:
            1 x Address Detail record including the word "Garage";
            1 x Tenancy Request (Bond Lodgment) record at "New" that will fail address validation for invalid keyword (i.e. using prepared address), not already associated to a Tenancy, not associated to a batch, Amount Paid with Lodgement matches Sum of Contributions, Managing Party client that does not already exist within AX;
            n x Tenancy Request Party records associated to the Tenancy Request using Client records that do not already exist within AX*/

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

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

            tenancyRequestPage.PopulateTenancyRequestWithNoInitialAndManagingParty(
                MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("REQUEST_TYPE")].Value.ToString(),
                MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("RENTAL_PREMISES")].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("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.CreateNewClient(managingParty);
            tenancyRequestPage = new TenancyRequestPage(driver);

            tenancyRequestPage.SetInitialRequestPartyWithSearch(initialRequestParty);
            tenancyRequestPage.SetDwellingTypeListValue("House");

            tenancyRequestPage.ClickSaveButton();

            string tenancyRequest = tenancyRequestPage.GetRequestNumber();
            StringAssert.Contains(tenancyRequest, "TR-BL-", "Validating the Tenancy Request saved with the correct TR no fromat");

            tenancyRequestPage.ClickSaveCloseButton();

            //Reopen the record and change the status reason to Ready for Validation and save.The record should show an exception with Invalid Keyword
            tenancyRequestSearchPage = new TenancyRequestsSearchPage(driver);
            tenancyRequestSearchPage.SetTenancyRequestSearchText(tenancyRequest);
            Table table = new Table(tenancyRequestSearchPage.GetSearchResultTable());
            StringAssert.Contains(table.GetCellValue("Name", tenancyRequest, "Status Reason"), "New");

            table.ClickCellValue("Name", tenancyRequest, "Name");

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

            tenancyRequestPage.SetStatusReason("Ready for validation");
            tenancyRequestPage.ClickSaveCloseButton();

            //Navigate to Queue - BL failed validation
            homePage.HoverRBSRibbonTab();
            homePage.ClickRtaQueuesButton();

            QueueSearchPage queuePage = new QueueSearchPage(driver);
            queuePage.SetPageFilterList("All Items");
            queuePage.SetQueue("Bond lodgement failed validation");

            Table queueTable = new Table(queuePage.GetSearchResultTable());

            //Open the Tenancy Request from the queue.Tenancy Request record displayed, status reason "Validation failed"at least one Request Queue Reason record created for invalid address keyword with status reason "To be resolved"

            queueTable.ClickCellContainsValue("Title", tenancyRequest, "Title");
            tenancyRequestPage = new TenancyRequestPage(driver);

            StringAssert.Contains(tenancyRequestPage.GetValidationStatusReason(), "Validation failed", "Validation should fail when invalid keyword entered in address details");

            //tenancyRequestPage.ClickQueueReasons();
            Table queueReasonTable = new Table(tenancyRequestPage.GetQueueReasonTable());
            StringAssert.Contains(queueReasonTable.GetCellContainsValue("Reason", "Invalid keyword detected", "Status Reason"), "To be resolved");

            //De-activate the Tenancy Request and refresh the record.Tenancy Request record updated with Status "Inactive", Status Reason "Cancelled", Tenancy not populated
            tenancyRequestPage.ClickDeactivateButton();

            WarningDialogueFramePage warningPage = new WarningDialogueFramePage(driver);
            warningPage.ClickProcessBeginButton();
            Thread.Sleep(5000);

            tenancyRequestPage = new TenancyRequestPage(driver);
            Assert.AreEqual(tenancyRequestPage.GetStatusReason(), "Cancelled", "Validating that TR:" + tenancyRequest + " Status Reason becomes Cancelled after deactivating the record");

            homePage.HoverRBSRibbonTab();
            homePage.ClickRtaTenancyRequestRibbonButton();

            //Validate whether TR found in the list of recent Inactive Tenancy Requests
            tenancyRequestSearchPage = new TenancyRequestsSearchPage(driver);
            tenancyRequestSearchPage.SetPageFilterList("Inactive Tenancy Requests");

            //Table tenancyRequestSearchHeaderTable = new Table(tenancyRequestSearchPage.GetHeaderSearchResultTable());
            //tenancyRequestSearchHeaderTable.ClickTableColumnHeader("Created On");
               // tenancyRequestSearchHeaderTable.ClickTableColumnHeader("Created On");

            Table tenancyRequestSearchTable = new Table(tenancyRequestSearchPage.GetSearchResultTable());
            StringAssert.Contains(tenancyRequestSearchTable.GetCellContainsValue("Name", tenancyRequest, "Name"), tenancyRequest,"Validating the inactive tenancy request table has the deactivated tenancy request");

            #region Shut down Excel
            MyBook.Save();
            MyBook.Close();
            MyApp.Quit();
            #endregion
        }
        public void ATC5511_CRMBPayReferenceNewLodgement()
        {
            #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() == "5511")
                {
                    MyRow = i;
                    break;
                }
            }
            #endregion

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

            string initialRequestParty = MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("INITIAL_REQUEST_PARTY")].Value.ToString();
            string initialContribution = MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("INITIAL_CONTRIBUTION")].Value.ToString();

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

            tenancyRequestsSearchPage.ClickNewTenancyRequestButton();

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

            tenancyRequestPage.PopulateMandatoryFieldValues(
              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(),
              initialRequestParty,
              MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("WEEKLY_RENT")].Value.ToString(),
              initialContribution,
              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());

            //Create New Batch Request from Tenancy Reuest Page and confirm batch number format correct
            string requestBatch = tenancyRequestPage.CreateNewBatchRequest(MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("MANAGING_PARTY")].Value.ToString(), MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("PAYMENT_TYPE")].Value.ToString());
            StringAssert.Contains(requestBatch, "TRB-BL-");

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

            tenancyRequestPage.ClickSaveCloseButton();

            tenancyRequestPage = new TenancyRequestPage(driver);

            //Open RBS>New BatchRequest
            homePage.HoverCRMRibbonTab();
            homePage.ClickRBSRibbonButton();
            homePage.HoverRBSRibbonTab();

            homePage.ClickRequestBatchRibbonButton();

            //Confirm Tenancy request listed in the New Batch Request
            RequestBatchesSearchPage requestBatchSearchPage = new RequestBatchesSearchPage(driver);
            requestBatchSearchPage.SetRequestBatchSearchText(requestBatch);

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

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

            Table trTable = new Table(requestBatchPage.GetTenancyRequestTable());

            string actualTenancyRequest = trTable.GetCellValue("Managing Party", MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("MANAGING_PARTY")].Value.ToString(),"Name");
            Assert.AreEqual(tenancyrequest, actualTenancyRequest,"Validating the Tenancy request listed in NewBatch Request");

            #region Shut down Excel
            MyBook.Save();
            MyBook.Close();
            MyApp.Quit();
            #endregion
        }
        public void ATC5506_CRMAutomaticallyrecordapaymentreferencenumberforthelodgement()
        {
            #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() == "TR_TestData")
                {
                    MyRow = i;
                    break;
                }
            }
            #endregion

            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();
            string initialRequestParty = MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("INITIAL_REQUEST_PARTY")].Value.ToString();
            string initialContribution = MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("INITIAL_CONTRIBUTION")].Value.ToString();
            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(),
              initialRequestParty,
              MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("WEEKLY_RENT")].Value.ToString(),
              initialContribution,
              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();
            MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("TR_NUMBER")].Value = tenancyrequest;
            StringAssert.Contains(tenancyrequest, "TR-BL-");
            tenancyRequestPage.ClickSaveCloseButton();

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

            homePage.ClickRequestBatchRibbonButton();

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

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

            //Add tenancy requests
            string TR1reference = MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("TR_NUMBER")].Value.ToString();
            requestBatchPage.ClickAddAssociatedRequestsButton();
            requestBatchPage.SetAssociatedRequest(TR1reference);

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

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

            requestBatchPage = new RequestBatchPage(driver);
            table = new Table(requestBatchPage.GetPaymentSummaryResultTable());
            table.GetCellValue("Request Batch", requestBatch, "Reference Number");

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

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

            StringAssert.Contains(tenancyRequestPage.GetFundedStatus(), "Payment pending");

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

            ClientsSearchPage clientsSearchPage = new ClientsSearchPage(driver);
            clientsSearchPage.SetClientSearchText("BLAIR TEST");

            Table table = new Table(clientsSearchPage.GetSearchResultTable());
            table.ClickCellValue("Full Name", "BLAIR TEST","Full Name");

            homePage.HoverClientXRibbonTab("BLAIR TEST");
            homePage.ClickClientXConnectionsRibbonButton();

            ClientPage clientPage = new ClientPage(driver);
            string BaseWindow = driver.CurrentWindowHandle;
            clientPage.SetConnectList("To Another");

            driver = clientPage.SwitchNewBrowser(driver, BaseWindow, "Connection");

            ConnectionPage connectionsPage = new ConnectionPage(driver);
            connectionsPage.ClickPageTitle();
            connectionsPage.SetNameText("BLAIR TEST");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Bankrupt");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Child");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Co Owner");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Colleague");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Co-Tenant");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Employee");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Employer");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("External Agency");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Former Employer");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Friend");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Licensee/Business Owner");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Neighbour");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("On Site Manager");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Owner/Lessor");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Parent");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Partner");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Potential Duplicate");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Primary Case");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Process Failure");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Property Manager");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Receiver");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Referral");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Referred by");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Related case");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Resident");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Spouse");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Stakeholder");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Tenant");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Witness");
            connectionsPage.ClickPageTitle();
            connectionsPage.SetAsThisRoleText("Managing Party");

            connectionsPage.SetStartDate("01/01/2015");
            connectionsPage.SetEndDate("01/02/2015");
            connectionsPage.SetDesctiptionText("Test description text");

            connectionsPage.ClickSaveIMG();

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

            clientPage = new ClientPage(driver);
            clientPage.ClickPageTitle();
            clientPage.SetClientSearchText("BLAIR TEST");

            table = new Table(clientPage.GetSearchResultTable());
            StringAssert.Contains(table.GetCellValue("Connected To", "BLAIR TEST", "Role (To)"), "Managing Party");
        }
        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 ATC6907_CRMOverrideInvalidKeywordExceptionQueue()
        {
            #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() == "6907")
                {
                    MyRow = i;
                    break;
                }
            }
            #endregion

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

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

            //Create new Tenancy Request. Fillup the Rental Premises with some address which has keyword like garage
            TenancyRequestsSearchPage tenancyRequestSearchPage = new TenancyRequestsSearchPage(driver);

            tenancyRequestSearchPage.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.SetDwellingTypeListValue("House");

            tenancyRequestPage.ClickSaveButton();

            string tenancyRequest = tenancyRequestPage.GetRequestNumber();
            StringAssert.Contains(tenancyRequest, "TR-BL-", "Validating the Tenancy Request saved with the correct TR no fromat");

            tenancyRequestPage.ClickSaveCloseButton();

            //Reopen the record and change the status reason to Ready for Validation and save.The record should show an exception with Invalid Keyword
            tenancyRequestSearchPage = new TenancyRequestsSearchPage(driver);
            tenancyRequestSearchPage.SetTenancyRequestSearchText(tenancyRequest);
            Table table = new Table(tenancyRequestSearchPage.GetSearchResultTable());
            StringAssert.Contains(table.GetCellValue("Name", tenancyRequest, "Status Reason"), "New");

            table.ClickCellValue("Name", tenancyRequest, "Name");

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

            tenancyRequestPage.SetStatusReason("Ready for validation");
            tenancyRequestPage.ClickSaveButton();
            StringAssert.Contains(tenancyRequestPage.GetValidationStatusReason(), "Validation failed", "Validation should fail when invalid keyword entered in address details");

            tenancyRequestPage.ClickQueueReasons();
            Table queueTable = new Table(tenancyRequestPage.GetQueueReasonTable());
            StringAssert.Contains(queueTable.GetCellContainsValue("Reason", "Invalid keyword detected", "Reason"), "Invalid keyword detected");

            UICommon.DoubleClickElement(queueTable.GetCellElementContainsValue("Reason", "Invalid keyword detected", "Status Reason"),driver);

            TenancyRequestQueueReasonStatusPage tenancyQueueReasonStatusPage = new TenancyRequestQueueReasonStatusPage(driver);
            Assert.IsFalse(tenancyQueueReasonStatusPage.GetOverrideCheckBoxValue(),"Validating the override checkbox for Invalid keyword queue reason is available for RBS officer");

               //Login with any other user other than RBS operation user and see the override can be done by that user

            driver.Close();
            driver = null;
            this.TestSetup();

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

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

            tenancyRequestSearchPage = new TenancyRequestsSearchPage(driver);

            tenancyRequestSearchPage.SetTenancyRequestSearchText(tenancyRequest);
            table = new Table(tenancyRequestSearchPage.GetSearchResultTable());

            table.ClickCellValue("Name", tenancyRequest, "Name");

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

            tenancyRequestPage.ClickQueueReasons();
            queueTable = new Table(tenancyRequestPage.GetQueueReasonTable());
            StringAssert.Contains(queueTable.GetCellContainsValue("Reason", "Invalid keyword detected", "Reason"), "Invalid keyword detected");

            //Open the exception queue and change the reason to resolved. In the tenancy record select a payment type and change the status reason to Ready for validation - SAVE
            UICommon.DoubleClickElement(queueTable.GetCellElementContainsValue("Reason", "Invalid keyword detected", "Status Reason"), driver);

            tenancyQueueReasonStatusPage = new TenancyRequestQueueReasonStatusPage(driver);
            tenancyQueueReasonStatusPage.SetOverrideCheckBox(true);

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

            StringAssert.Contains(tenancyRequestPage.GetAlertMessage(), "Your changes have not been saved");

            homePage.HoverRBSRibbonTab();
            homePage.ClickRtaTenancyRequestRibbonButton();

            //Create new Tenancy Request with fields populated except Payment type
            tenancyRequestSearchPage = new TenancyRequestsSearchPage(driver);

            tenancyRequestSearchPage.SetTenancyRequestSearchText(tenancyRequest);
            table = new Table(tenancyRequestSearchPage.GetSearchResultTable());

            table.ClickCellValue("Name", tenancyRequest, "Name");

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

            tenancyRequestPage.ClickQueueReasons();
            queueTable = new Table(tenancyRequestPage.GetQueueReasonTable());
            StringAssert.Contains(queueTable.GetCellContainsValue("Reason", "Invalid keyword detected", "Override"), "No");

            //Once override is done for that tenancy record for Invalid Keyword exception, it should appear as resolved in the queue in subsequent validations.
            //Validation should be successful
            driver.Close();
            driver = null;

            this.TestSetup();

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

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

            tenancyRequestSearchPage = new TenancyRequestsSearchPage(driver);

            tenancyRequestSearchPage.SetTenancyRequestSearchText(tenancyRequest);
            table = new Table(tenancyRequestSearchPage.GetSearchResultTable());

            table.ClickCellValue("Name", tenancyRequest, "Name");

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

            tenancyRequestPage.ClickQueueReasons();
            queueTable = new Table(tenancyRequestPage.GetQueueReasonTable());
            StringAssert.Contains(queueTable.GetCellContainsValue("Reason", "Invalid keyword detected", "Reason"), "Invalid keyword detected");

            UICommon.DoubleClickElement(queueTable.GetCellElementContainsValue("Reason", "Invalid keyword detected", "Status Reason"), driver);

            tenancyQueueReasonStatusPage = new TenancyRequestQueueReasonStatusPage(driver);
            tenancyQueueReasonStatusPage.SetOverrideCheckBox(true);
            tenancyQueueReasonStatusPage.ClickSaveCloseButton();

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

            tenancyRequestPage.ClickQueueReasons();
            queueTable = new Table(tenancyRequestPage.GetQueueReasonTable());
            StringAssert.Contains(queueTable.GetCellContainsValue("Reason", "Invalid keyword detected", "Override"), "Yes");

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

            queueTable = new Table(tenancyRequestPage.GetQueueReasonTable());
            StringAssert.Contains(queueTable.GetCellContainsValue("Reason", "Invalid keyword detected", "Status Reason"), "Resolved");

            #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 ATC6908_CRMUpdateTenancyRequestPaymentTypeExceptionQueue()
        {
            #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() == "TR_TestData")
                {
                    MyRow = i;
                    break;
                }
            }
            #endregion

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

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

            //Create new Tenancy Request with fields populated except Payment type
            TenancyRequestsSearchPage tenancyRequestSearchPage = new TenancyRequestsSearchPage(driver);

            tenancyRequestSearchPage.ClickNewTenancyRequestButton();

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

            tenancyRequestPage.PopulateTenancyRequestWithoutPaymentType(
                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());

            //Record should save successfully
            tenancyRequestPage.ClickSaveButton();

            string tenancyRequest = tenancyRequestPage.GetRequestNumber();
            StringAssert.Contains(tenancyRequest, "TR-BL-","Validating the Tenancy Request saved with the correct TR no fromat");

            tenancyRequestPage.ClickSaveCloseButton();

            //Open the record again and change the Status Reason to Ready for validation and save
            tenancyRequestSearchPage = new TenancyRequestsSearchPage(driver);
            tenancyRequestSearchPage.SetTenancyRequestSearchText(tenancyRequest);
            Table table = new Table(tenancyRequestSearchPage.GetSearchResultTable());
            StringAssert.Contains(table.GetCellValue("Name", tenancyRequest, "Status Reason"), "New");

            table.ClickCellValue("Name", tenancyRequest, "Name");

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

            tenancyRequestPage.SetStatusReason("Ready for validation");
            tenancyRequestPage.ClickSaveButton();
            StringAssert.Contains(tenancyRequestPage.GetValidationStatusReason(), "Validation failed","Validation should fail when payment type is balnk");

            //There should be one exception in the queue for Pyment type missing
            tenancyRequestPage.ClickQueueReasons();
            Table queueTable = new Table(tenancyRequestPage.GetQueueReasonTable());
            StringAssert.Contains(queueTable.GetCellContainsValue("Reason", "Payment Type is blank", "Reason"), "Payment Type is blank");

            //Open the exception queue and change the reason to resolved. In the tenancy record select a payment type and change the status reason to Ready for validation - SAVE
            UICommon.DoubleClickElement(queueTable.GetCellElementContainsValue("Reason", "Payment Type is blank", "Status Reason"), driver);

            TenancyRequestQueueReasonStatusPage tenancyQueueReasonStatusPage = new TenancyRequestQueueReasonStatusPage(driver);

            StringAssert.Contains(tenancyQueueReasonStatusPage.GetReasonValue(), "Payment Type is blank");
            tenancyQueueReasonStatusPage.SetReasonValue("Resolved");
            tenancyQueueReasonStatusPage.ClickSaveCloseButton();

            tenancyRequestPage = new TenancyRequestPage(driver);
            tenancyRequestPage.SetPaymentType("BPay");

            tenancyRequestPage.ClickSaveButton();
            //Record should be saved and validation should be successful
            tenancyRequestPage.SetStatusReason("Ready for validation");
            tenancyRequestPage.ClickSaveButton();
            StringAssert.Contains(tenancyRequestPage.GetValidationStatusReason(), "Validation successful","Validation should be successful after adding payment type");

            #region Shut down Excel
            MyBook.Save();
            MyBook.Close();
            MyApp.Quit();
            #endregion
        }
        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 ATC7632_TopUpEFTReferenceTRSuccessful()
        {
            #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() == "7632")
                {
                    MyRow = i;
                    break;
                }
            }
            #endregion

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

            //Attemp to save with Mandatory data
            string managingParty = MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("MANAGING_PARTY")].Value.ToString();
            tenancyRequestPage.PopulateTenancyRequestTopUpValidationSuccessful(
                MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("REQUEST_TYPE")].Value.ToString(),
                MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("RENTAL_PREMISES")].Value.ToString(),
                managingParty,
                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(),
                MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("TENANCY")].Value.ToString());

            tenancyRequestPage.ClickSaveButton();
            string tenancyrequest = tenancyRequestPage.GetRequestNumber();
            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);

            Assert.IsTrue(tenancyRequestsSearchPage.GetPaymentRefernceRefreshTable(tenancyrequest));
            Table table = new Table(tenancyRequestPage.GetPaymentSummaryResultTable());
            table.ClickCellValue("Name", tenancyrequest, "Name");

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

            //asserts if Payment Reference Number is >= 30000000
            string referencenumber = table.GetCellValue("Tenancy Request", tenancyrequest, "Reference Number");
            StringAssert.StartsWith(referencenumber, "3");
            Assert.IsTrue(referencenumber.Length == 8);
            Assert.IsTrue(int.Parse(referencenumber.Substring(1).TrimStart('0')) > 0);

            StringAssert.Contains(tenancyRequestPage.GetStatusReason(), "Pending Financials");

            //asserts if record is read only
            Console.Write(tenancyRequestPage.GetRecordStatus());
            StringAssert.Equals(tenancyRequestPage.GetRecordStatus(), "Read only");

            #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 ATC9851_CRMChangeOfMPMandatoryFieldsValidationsAC3NoContributorsExceptionOverride()
        {
            #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() == "9851")
                {
                    MyRow = i;
                    break;
                }
            }
            #endregion

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

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

            TenancyRequestsSearchPage tenancyRequestSearchPage = new TenancyRequestsSearchPage(driver);

            //Click [+NEW] button.
            tenancyRequestSearchPage.ClickNewTenancyRequestButton();

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

            //Set {Type} field to Change of Managing Party.
            //
            tenancyRequestPage.SetRequestTypeListValue("Change of Managing Party");

            //Populate all other mandatory fields required for successful validation (as per stories 6792/6793) without a Request Party
            tenancyRequestPage.PopulateTenancyRequestChangeOfManagingPartyWithoutRequestParty(
                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")].Value.ToString(),
                MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("MISC1")].Value.ToString(),
                DateTime.Now.ToString("dd/MM/yyyy"),
                DateTime.Now.ToString("dd/MM/yyyy"),
                DateTime.Now.ToString("dd/MM/yyyy"),
                DateTime.Now.ToString("dd/MM/yyyy"),
                "Signature verified",
                "Signature verified");

            //Click [Save] button to unlock {Status Reason}
            tenancyRequestPage.ClickSaveButton();

            //Set {Status Reason} to "Ready for validation".
            tenancyRequestPage.SetStatusReason("Ready for validation");

            //Click [Save] button.
            tenancyRequestPage.ClickSaveButton();

            //Assert: {Status Reason} becomes "Validation failed".
            StringAssert.Equals(tenancyRequestPage.GetStatusReason(), "Validation failed");

            //Inspect Queue Reasons section.
            tenancyRequestPage.ClickQueueReasons();  //This may not be necessary.

            //Assert: An exception queue entry is created with reason type: "At least one contributor required"
            Table table = new Table(tenancyRequestPage.GetQueueReasonTable());
            StringAssert.Contains(table.GetCellContainsValue("Reason", "Invalid number of contributors", "Reason"), "Invalid number of contributors");

            //Double-click on exception queue record.
            //UICommon.DoubleClickElement(table.GetCellElementContainsValue("Reason", "Invalid Contributor : At least one contributor required", "Status Reason"), driver);
            table.ClickCellContainsValueEnterRow("Reason", "Invalid number of contributors", "Status Reason");
            TenancyRequestQueueReasonPage tenancyRequestQueueReasonPage = new TenancyRequestQueueReasonPage(driver);

            //Click {Override} checkbox to select/tick it.
            tenancyRequestQueueReasonPage.SetOverrideCheckBox(true);

            //Click [SAVE & CLOSE] button.
            tenancyRequestQueueReasonPage.ClickSaveCloseButton();
            tenancyRequestPage = new TenancyRequestPage(driver);

            //Set {Status Reason} to "Ready for validation".
            tenancyRequestPage.SetStatusReason("Ready for validation");

            //Click [Save] button.
            tenancyRequestPage.ClickSaveButton();

            string tenancyRequest = tenancyRequestPage.GetRequestNumber();
            tenancyRequestPage.ClickSaveCloseButton();

            tenancyRequestSearchPage = new TenancyRequestsSearchPage(driver);
            tenancyRequestSearchPage.SetTenancyRequestSearchText(tenancyRequest);

            table = new Table(tenancyRequestSearchPage.GetSearchResultTable());
            table.GetCellValue("", "", "");
            //Assert: {Status Reason} becomes "Validation successful".
            //StringAssert.Contains(tenancyRequestPage.GetStatusReason(), "Validation successful");

            #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 ATC4400_CRM1514EnterdataManagementTypes()
        {
            #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() == "4400")
                {
                    MyRow = i;
                    break;
                }
            }
            #endregion

            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 tenancyRequestSearchPage = new TenancyRequestsSearchPage(driver);
            tenancyRequestSearchPage.ClickNewTenancyRequestButton();

            TenancyRequestPage tenancyRequestPage = new TenancyRequestPage(driver);
            tenancyRequestPage.ClickPageTitle();
            tenancyRequestPage.PopulateTenancyRequestFormResidentialTenancy(
               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("INITIAL_CONTRIBUTION")].Value.ToString(),
               MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("AMOUNT_PAID_LODGEMENT")].Value.ToString(),
               MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("LODGEMENT_TYPE")].Value.ToString());

            //tenancyRequestPage.ClickSaveButton();

            ////Assert Management Type field
            Assert.IsTrue(tenancyRequestPage.GetTenancyManagementTypeListValue("Lessor/Owner"));
            Assert.IsTrue(tenancyRequestPage.GetTenancyManagementTypeListValue("Real Estate Agent"));
            Assert.IsTrue(tenancyRequestPage.GetTenancyManagementTypeListValue("Moveable dwelling owner/manager"));
            Assert.IsTrue(tenancyRequestPage.GetTenancyManagementTypeListValue("Community Housing Organisation"));
            //Assert.IsTrue(tenancyRequestPage.GetRTATenancyManagementTypeListValue("Other));

            ////Change Tenancy type
            tenancyRequestPage.SetResidentialTenancyTypeList("Rooming Accommodation");
            tenancyRequestPage.SetResidentialManagementTypeList("Lessor/Owner");
            ////Assert Dwelling Type field
            Assert.IsTrue(tenancyRequestPage.GetTenancyManagementTypeListValue("Lessor/Owner"));
            Assert.IsTrue(tenancyRequestPage.GetTenancyManagementTypeListValue("Real Estate Agent"));
            Assert.IsTrue(tenancyRequestPage.GetTenancyManagementTypeListValue("Manager/provider"));
            //Assert.IsTrue(tenancyRequestPage.GetRTATenancyManagementTypeListValue("Other));

            //Assert Save Successful
            tenancyRequestPage.ClickSaveButton();
            StringAssert.Contains(tenancyRequestPage.GetRequestNumber(), "TR-BL-");

            string tenancyRequest = tenancyRequestPage.GetRequestNumber();
            tenancyRequestPage.ClickSaveCloseButton();

            //Assert record in search table
            tenancyRequestSearchPage = new TenancyRequestsSearchPage(driver);
            tenancyRequestSearchPage.SetTenancyRequestSearchText(tenancyRequest);
            Table table = new Table(tenancyRequestSearchPage.GetSearchResultTable());
            StringAssert.Contains(table.GetCellValue("Name", tenancyRequest, "Name"), tenancyRequest);

            #region Shut down Excel
            MyBook.Save();
            MyBook.Close();
            MyApp.Quit();
            #endregion
        }
        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 ATC4394_CRMEnterdatafromForm()
        {
            #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() == "4394")
                {
                    MyRow = i;
                    break;
                }
            }
            #endregion

            string tenancyRequest;
            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 tenancyRequestSearchPage = new TenancyRequestsSearchPage(driver);

            tenancyRequestSearchPage.ClickNewTenancyRequestButton();

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

            //tenancyRequestPage.PopulateTenancyRequestFormResidentialTenancy("1 THOMAS ST, BIRKDALE, QLD, 4159", "Residential Tenancy", "AMANDA TEST", "3", "AARON BALL", "700", "700", "Initial");
            tenancyRequestPage.PopulateTRNoTenancyType(
               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("INITIAL_CONTRIBUTION")].Value.ToString(),
               MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("AMOUNT_PAID_LODGEMENT")].Value.ToString(),
               MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("LODGEMENT_TYPE")].Value.ToString());

            tenancyRequestPage.ClickSaveButton();
            tenancyRequestPage.ClickSaveButton();
            //Assert Save unsuccessful without Tenancy Type
            StringAssert.StartsWith(tenancyRequestPage.GetTenancyTypeErrorText(), "You must provide a value for Tenancy Type.");
            tenancyRequestPage.ClickPageTitle();
            tenancyRequestPage.SetResidentialTenancyTypeList("Residential Tenancy");
            tenancyRequestPage.SetResidentialManagementTypeList("Lessor/Owner");
            //Assert Save Successful
            tenancyRequestPage.ClickSaveButton();
            StringAssert.Contains(tenancyRequestPage.GetRequestNumber(), "TR-BL-");
            tenancyRequest = tenancyRequestPage.GetRequestNumber();

            //Assert List Values
            //tenancyRequestPage.ClickTenancyTypeList();
            Assert.IsTrue(tenancyRequestPage.GetTenancyTypeListValue("Residential Tenancy"));
            Assert.IsTrue(tenancyRequestPage.GetTenancyTypeListValue("Rooming Accommodation"));
            tenancyRequestPage.SetResidentialManagementTypeList("Lessor/Owner");

            tenancyRequestPage.ClickSaveCloseButton();

            //Assert record in search table
            tenancyRequestSearchPage = new TenancyRequestsSearchPage(driver);
            tenancyRequestSearchPage.SetTenancyRequestSearchText(tenancyRequest);
            Table table = new Table(tenancyRequestSearchPage.GetSearchResultTable());
            StringAssert.Contains(table.GetCellValue("Name", tenancyRequest, "Status Reason"), "New");

            #region Shut down Excel
            MyBook.Save();
            MyBook.Close();
            MyApp.Quit();
            #endregion
        }
Exemplo n.º 29
0
        public static bool GetPaymentRefernceRefreshTable(string reference, Table t, IWebDriver d)
        {
            int i = 1;
            while (i <= 60) //waits for 60sec
            {

                if (t.GetCellValue("Name", reference, "Status Reason") == "Pending Financials")
                {
                    return true;

                }
                else
                {
                    Thread.Sleep(1000);
                    WebDriverWait wait = new WebDriverWait(d, TimeSpan.FromSeconds(waitsec));
                    wait.Until(ExpectedConditions.ElementIsVisible(By.Id("grid_refresh"))).Click();
                    i++;
                }

            } throw new Exception(String.Format("Status Reason has not changed to Pending Financials"));
        }
        public void ATC3350_CRMEntityClientAddressCreateNew()
        {
            #region Start Up Excel
            MyBook = MyApp.Workbooks.Open(DatasourceDir + @"\Clients.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() == "3350")
                {
                    MyRow = i;
                    break;
                }
            }
            #endregion

            string address = (MyRange.Cells[MyRow, ClientsSchema.GetColumnIndex("ADDRESS")].Value.ToString());

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

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

            clientsSearchPage.ClickNewClientButton();

            ClientPage clientPage = new ClientPage(driver);
            clientPage.ClickPageTitle();
            clientPage.SetClientType("Person");
            clientPage.SetFamilyName("TESTING ADDRESS");
            clientPage.ClickSaveButton();
            string clientID = clientPage.GetClientID();
            homePage.HoverClientXRibbonTab("TESTING ADDRESS");
            homePage.ClickClientXAddressesRibbonButton();
            string BaseWindow = driver.CurrentWindowHandle;

            clientPage = new ClientPage(driver);
            Thread.Sleep(3000);
            clientPage.ClickAddNewClientAddressImage();
            driver = clientPage.SwitchNewBrowser(driver, BaseWindow, "Client Address:");
            ClientNewAddressPage clientNewAddressPage = new ClientNewAddressPage(driver);
            clientNewAddressPage.ClickPageTitle();
            clientNewAddressPage.SetAddressDetails("*" + address);
            clientNewAddressPage.ClickSaveButton();
            clientNewAddressPage.GetCleintAddress();

            Trace.Listeners.Add(new TextWriterTraceListener("TextWriterOutput.log", "myListener"));
            Trace.TraceInformation("Add New Address End:" + DateTime.Now.ToString("ddMMyyyyhhmmssffff"));
            Trace.Flush();

            clientNewAddressPage.ClickSaveAndClose();

            driver = driver.SwitchTo().Window(BaseWindow);
            clientPage = new ClientPage(driver);
            clientPage.ClickPageTitle();
            clientPage = new ClientPage(driver);
            clientPage.SetPostalAddress("*" + address);
            clientPage.ClickSaveCloseButton();
            clientsSearchPage = new ClientsSearchPage(driver);
            clientsSearchPage.SetClientSearchText(clientID);
            Table table = new Table(clientsSearchPage.GetSearchResultTable());
            Assert.AreEqual(table.GetCellValue("RTA Client Id", clientID, "Postal Address"), address, "Address comparison failed");

            #region Shut down Excel
            MyBook.Save();
            MyBook.Close();
            MyApp.Quit();
            #endregion
        }