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 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
        }